Score:2

Ubuntu 20.04 LTS complete system freeze when watching YouTube videos

in flag

After about a minute of watching any youtube video on either Chrome or Firefox the computer becomes completely unresponsive, screen is stuck, audio is looping the last second, the computer does not even register headphones being plugged into the 3.5mm jack. This is a problem that seems to have come out of the blue as I have not made any hardware or software changes, the only things the machine was used was general internet browsing, and watching online and locally stored videos. The freeze only seems to go away if I hard shutdown the computer, and persists after several reboots. The problem only seems to affect youtube, VLC and other sites like twitch work fine.

Output of neofetch:

            .-/+oossssoo+/-.               barba@lenovo 
        `:+ssssssssssssssssss+:`           ------------- 
      -+ssssssssssssssssssyyssss+-         OS: Ubuntu 20.04.2 LTS x86_64 
    .ossssssssssssssssssdMMMNysssso.       Host: 81LK IdeaPad L340-15IRH Gaming 
   /ssssssssssshdmmNNmmyNMMMMhssssss/      Kernel: 5.11.0-25-generic 
  +ssssssssshmydMMMMMMMNddddyssssssss+     Uptime: 12 mins 
 /sssssssshNMMMyhhyyyyhmNMMMNhssssssss/    Packages: 2289 (dpkg), 6 (snap) 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Shell: bash 5.0.17 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   Resolution: 1920x1080 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   DE: GNOME 
ossyNMMMNyMMhsssssssssssssshmmmhssssssso   WM: Mutter 
+sssshhhyNMMNyssssssssssssyNMMMysssssss+   WM Theme: Adwaita 
.ssssssssdMMMNhsssssssssshNMMMdssssssss.   Theme: Adwaita-dark [GTK2/3] 
 /sssssssshNMMMyhhyyyyhdNMMMNhssssssss/    Icons: Yaru [GTK2/3] 
  +sssssssssdmydMMMMMMMMddddyssssssss+     Terminal: gnome-terminal 
   /ssssssssssshdmNNNNmyNMMMMhssssss/      CPU: Intel i7-9750H (12) @ 2.600GHz 
    .ossssssssssssssssssdMMMNysssso.       GPU: Intel UHD Graphics 630 
      -+sssssssssssssssssyyyssss+-         GPU: NVIDIA GeForce GTX 1650 Mobile  
        `:+ssssssssssssssssss+:`           Memory: 1283MiB / 7835MiB 
            .-/+oossssoo+/-.

Attempted fixes and diagnostics:

  • running the browser from a terminal shows no error codes prior to the freeze
  • updating to the latest software using sudo apt upgrade
  • hardware usage graphs and temperatures all look normal until freeze (as reported by System monitor and sensors)
  • increasing swap file size to 4G and increasing vm.swappiness to 60 (this fix only seems to delay the problem,but it still exists)

output of free -h, sysctl vm.swappiness & swapon -s as suggested by @heynnema:

              total        used        free      shared  buff/cache   available
Mem:          7,7Gi       1,2Gi       5,5Gi        29Mi       964Mi       6,2Gi
Swap:         472Mi          0B       472Mi
vm.swappiness = 10
Filename                Type        Size    Used    Priority
/swapfile               file        483896  0       -2
  • output of top at the moment of freeze I am using firefox to browse the web, but I have also tested Chrome and the problem persists.
  • The nVidia driver was installed manually as Software & Updates wasn't downloading working drivers for whatever reason. The specific version is 460.91.03, as shown by nvidia-smi
  • Output of sudo dmidecode -s bios-version: BGCN33WW
  • Using the intel gpu does not help, in fact it is easier to cause the bug when using it
  • NEW output of free -h:
              total        used        free      shared  buff/cache   available
Mem:          7,7Gi       1,2Gi       5,3Gi       157Mi       1,1Gi       6,0Gi
Swap:         4,0Gi          0B       4,0Gi
  • NEW output of sysctl vm.swappiness:
vm.swappiness = 60
  • NEW output of swapon -s:
Filename                Type        Size    Used    Priority
/swapfile               file        4194300 0       -2
  • output of grep -i swap /etc/fstab:
 /swapfile  none  swap  sw  0  0
heynnema avatar
ru flag
Edit your question and show me `free -h` and `sysctl vm.swappiness` and `swapon -s`. Start comments to me with @heynnema or I'll miss them.
Freddy Daniel avatar
ve flag
Try another linux distro and check if the problem persists.
barba avatar
in flag
@heynnema thanks for posting! I've added the stuff you requested.
Score:1
ru flag

Your /swapfile is way too small, and your vm.swappiness is totally wrong.

Let's increase your /swapfile to 4G, and set vm.swappiness to a more appropriate value.

/swapfile

Note: Incorrect use of the rm and dd commands can cause data loss. Suggest copy/paste.

In the terminal...

sudo swapoff -a           # turn off swap
sudo rm -i /swapfile      # remove old /swapfile

sudo dd if=/dev/zero of=/swapfile bs=1M count=4096

sudo chmod 600 /swapfile  # set proper file protections
sudo mkswap /swapfile     # init /swapfile
sudo swapon /swapfile     # turn on swap
free -h                   # confirm 8G RAM and 4G swap

Edit /etc/fstab, using sudo -H gedit /etc/fstab or sudo pico /etc/fstab.

Confirm this /swapfile line in /etc/fstab... and confirm no other “swap” lines... use SPACES in this line... confirm NO TABS...

/swapfile  none  swap  sw  0  0

reboot                    # reboot and verify operation

vm.swappiness

Edit /etc/sysctl.conf

sudo -H gedit /etc/sysctl.conf

Find the line that has vm.swappiness=10 and set it =60.

Save the file and quit gedit.

sudo sysctl -p

Update #1:

BIOS

You have BIOS version BGCN33WW. A newer BIOS, version BGCN34WW, is available here or here. Although I don't believe that it'll fix your problem, it's always a good idea to keep current with BIOS updates for security fixes.

NVIDIA

You have Nvidia driver 460.91.03. Version 470.57 is available here. This tested driver should also be installable in Software & Updates app. Because the problem is recreatable when using the Intel GPU, I don't suspect that this will fix the problem either, but again, it's always good to stay current.

MEMTEST

Because symptoms improved when we changed the /swapfile and vm.swappiness, we need to check your memory.

Go to https://www.memtest86.com/ and download/run their free memtest to test your memory. Get at least one complete pass of all the 4/4 tests to confirm good memory. This may take many hours to complete.

SWAP

I just looked at the top and free -h outputs again, and your /swapfile appears to not be active. Did you confirm that the swap line in /etc/fstab has no tabs in it?

Curious... examples of free -h before and after the /swapfile change show zero swap usage...

              total        used        free      shared  buff/cache   available
Mem:          7,7Gi       1,2Gi       5,5Gi        29Mi       964Mi       6,2Gi
Swap:         472Mi          0B       472Mi

and

              total        used        free      shared  buff/cache   available
Mem:          7,7Gi       1,2Gi       5,3Gi       157Mi       1,1Gi       6,0Gi
Swap:         4,0Gi          0B       4,0Gi

Also, the top command, when looked at when the computer was frozen, also shows zero swap usage.

cn flag
Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/128392/discussion-on-answer-by-heynnema-ubuntu-20-04-lts-complete-system-freeze-when-wa).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.