FreeTubeApp / FreeTube

An Open Source YouTube app for privacy
https://freetubeapp.io/
GNU Affero General Public License v3.0
12.65k stars 779 forks source link

[Bug]: App stops playing (pauses) when it goes to background #4899

Open calvaris opened 3 months ago

calvaris commented 3 months ago

Guidelines

Describe the bug

  1. Paste a Youtube URL
  2. play
  3. move out of focus of the app, to have it on background

Expected Behavior

app should not stop playing but it does

Issue Labels

feature stopped working

FreeTube Version

v0.20.0 Beta

Operating System Version

Debian testing

Installation Method

Flathub

Primary API used

Local API

Last Known Working FreeTube Version (If Any)

No response

Additional Information

No response

Nightly Build

raphraph commented 3 months ago

Same here on Ubuntu 22.04 and with Freetube v0.20.0 Beta installed from official download (https://github.com/FreeTubeApp/FreeTube/releases/download/v0.20.0-beta/freetube_0.20.0_amd64.deb).

The pausing does not occur instantly, it takes sometimes a few dozens of seconds, but it always stops.

The pausing does not occur if there is a Freetube window not in background, even if it is not the window which is playing.

sameersharma2006 commented 3 months ago

Can confirm the same in the snap package with the latest version.

Terminal logs,maybe relevant ?

[19376:0410/141917.655994:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 1 times!
[19376:0410/141917.655994:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 1 times!
[19376:0410/142106.622690:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 2 times!
[19376:0410/142109.298473:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 3 times!
xe-3 commented 3 months ago

Can confirm the same in the snap package with the latest version.

Terminal logs,maybe relevant ?

[19376:0410/141917.655994:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 1 times!
[19376:0410/141917.655994:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 1 times!
[19376:0410/142106.622690:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 2 times!
[19376:0410/142109.298473:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 3 times!

I also do not know if those errors are relevant or not. But I'm seeing a similar error messages as well:

[2:0411/104322.988551:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:0411/104322.988627:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[45:0411/104325.809057:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 1 times!
[45:0411/104338.036726:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 2 times!
[45:0411/104338.047335:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 3 times!

(in my case: Flatpak version of Freetube 0.20 Beta installed, on Linux (Fedora 40 Beta and Gnome 46)

A little searching gave me the impression these messages relate to an upstream issue in Electron and/or Chromium.

psychon-night commented 3 months ago

Same bug here. Ubuntu 23.04, installed from the download page (AppImage version)

[201778:0411/182422.985639:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 1 times!
[201778:0411/183514.618333:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 2 times!
[201778:0411/183533.852878:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 3 times!

These are still showing up when the window is visible but unfocused (on a second monitor) but playback is NOT interrupted

These also show up on a single-monitor setup when the app loses focus. In that case, it does stop playback

efb4f5ff-1298-471a-8973-3d47447115dc commented 3 months ago

@JoshuaMacklin could you maybe look into this? There have been allot of bug reports opened since release that are all linux (some also exclusive to flatpak) related. To see all the issue use label filter OS: linux

JoshuaMacklin commented 3 months ago

I can take a look into this next week when I am free, I also only noticed this after the 0.20 update, can’t believe it’s anything related to the flathub version changes we’ve recently made as I’ve had them back ported to 0.19 for months

nooraibk commented 3 months ago

I'm on latest release from flatpak and am having same issue on fedora 39, app stops playing until it is focused.

fadri14 commented 3 months ago

Hello, I have the same problem on arch linux with the AUR package.

aidzm commented 3 months ago

Just wanted to confirm that I'm experiencing the same issue. Currently, running Fedora Kinoite (Atomic KDE) 40 and using the Flathub version 0.20.0 beta.

This can be easily reproduced on KDE by switching to another virtual desktop, which would cause the video to stop playing after a while (and sporadically play-stop-play), despite it being on the foreground in the other virtual desktop.

JoshuaMacklin commented 3 months ago

Very well could be originating from upstream electron as more people on linux specifically are commenting on it recently. https://github.com/electron/electron/issues/32760

However I did notice on Bazzite Gnome (Gaming oriented Fedora Silverblue w/ extra packages) is not affected even in background and another workspace for an hour. However they do add extra VRR / Video Syncing packages that may be fixing the vsync / sync issues that are arising for others on more stock linux operating systems.

My ask to the others that are running into this problem, are you all getting the same GetVSyncParametersIfAvailable() failed terminal logs? Do you use Variable / High Refresh Rate screens? And even possibly trying out the latest dev build appimage to see if the issue may be solved with a slightly more updated electron version.

https://github.com/FreeTubeApp/FreeTube/actions/runs/8753729711

toby63 commented 3 months ago

@fadri14

Hello, I have the same problem on arch linux with the AUR package.

Could you give more details? Because I am using the latest master on ArchLinux, with KDE, Electron 29 and I don't have this issue.

fadri14 commented 3 months ago

Well, actually. Now I have another problem. When I launch the application, it quits directly. There's this error in the terminal: /usr/bin/freetube : ligne 3 : 4263 Erreur de segmentation (core dumped)electron /usr/lib/freetube/app.asar "$@"

toby63 commented 3 months ago

@fadri14 See: https://aur.archlinux.org/cgit/aur.git/commit/?h=freetube&id=035f14135bd1eb6277a00767f4f1fd57eba760c5 You probably have to update, to use Electron29.

But this is offtopic, could you provide more details on your setup for the main problem discussed here? Do you use Gnome or something else etc.?

fadri14 commented 3 months ago

@toby63 Ok thanks, for the info. Indeed, it solved this problem and I can now say that the error message is as follows

[37788:0420/154330.343621:ERROR:gl_surface_presentation_helper.cc(260)] GetVSyncParametersIfAvailable() failed for 1 times!

Besides, I don’t use desktop environment. I use sway window manager

xe-3 commented 3 months ago

Do you use Variable / High Refresh Rate screens?

In my case no. I'm on a Dell XPS laptop with a 60 hz FHD display.

zestygrass commented 3 months ago

experiencing the same issue on Flatpak version on Fedora 40 with Plasma 6.

0Raik commented 2 months ago

experiencing the same issue on Flatpak verision on Manjaro latest with Gnome 46

T-vK commented 2 months ago

Same here. Been having these issues for weeks, even with the latest FreeTube v0.20.0 Beta (Flatpak).

System Details Report


Report details

Hardware Information:

Software Information:


System logs

No related logs in journalctl.


Frontend logs

The only line popping out is:

VIDEOJS: WARN: using Vhs.BANDWIDTH_VARIANCE is UNSAFE be sure you know what you are doing

Not sure if it is related.


Frontend events

Logging events like onvisibilitychange shows that the frontend is not able to use these to distinguish between the window getting minimized or losing focus:

document.onvisibilitychange = () => console.log(document.hidden ? 'Minimized or Unfocused' : 'Restored or Focused');
window.onblur = () => console.log('Window Blurred');
window.onfocus = () => console.log('Window Focused');
window.onresize = () => console.log('Window Resized');
window.onbeforeunload = () => console.log('Window About to Unload');
window.onunload = () => console.log('Window Unloaded');
document.addEventListener('focusin', () => console.log('Element Focused In'));
document.addEventListener('focusout', () => console.log('Element Focused Out'));
psychon-night commented 2 months ago

My ask to the others that are running into this problem, are you all getting the same GetVSyncParametersIfAvailable() failed terminal logs? Do you use Variable / High Refresh Rate screens? And even possibly trying out the latest dev build appimage to see if the issue may be solved with a slightly more updated electron version.

Yes to the log question, and yes to owning an HRR screen. However, this issue still occurs when my 165hz monitor is not connected. My laptop's built-in display runs at 60hz

Using the build you linked, I am still experiencing the same issues. When the application is in the background, I get long periods of buffering, then a few seconds of audio... then more buffering.

In addition, I tried on the most recent build and still get the issue here

aidzm commented 2 months ago

Very well could be originating from upstream electron as more people on linux specifically are commenting on it recently. https://github.com/electron/electron/issues/32760

However I did notice on Bazzite Gnome (Gaming oriented Fedora Silverblue w/ extra packages) is not affected even in background and another workspace for an hour. However they do add extra VRR / Video Syncing packages that may be fixing the vsync / sync issues that are arising for others on more stock linux operating systems.

My ask to the others that are running into this problem, are you all getting the same GetVSyncParametersIfAvailable() failed terminal logs? Do you use Variable / High Refresh Rate screens? And even possibly trying out the latest dev build appimage to see if the issue may be solved with a slightly more updated electron version.

https://github.com/FreeTubeApp/FreeTube/actions/runs/8753729711

I can confirm that the terminal log shows up. I have tested on 60Hz monitor (laptop) and 75Hz monitor, no VRR and High RR. I'll try out the dev build when I'm done with my next paper. Finals season rn.

Edit: Just wanted to say, Freetube is a critical software due to my heavy usage for studying. I thank all the contributors and maintainers for developing such a GOATed project :)

T-vK commented 2 months ago

I also think it is most likely the electron version causing this issue. Installing FreeTube from AUR instead of the Flatpak, it works just fine.

stpnwf commented 2 months ago

Any updates on this? It is so freaking annoying.

T-vK commented 2 months ago

Maybe someone just needs to update the electron version of the Flatpak to 29. Seems to be at 23.08 right now: https://github.com/flathub/io.freetubeapp.FreeTube/blob/26d154dacc2bfd4e81abe598f4c4053f56f76b62/io.freetubeapp.FreeTube.yml#L7

efb4f5ff-1298-471a-8973-3d47447115dc commented 2 months ago

That base version is unrelated to the actual Electron version

See documentation:

And repo that base version is linked to:

MininuxDev commented 1 month ago

For other people with this issue who absolutely need freetube, a workaround i am using for now is disabling hardware acceleration. There doesn't seem to be a setting to change this (or at least i haven't found it) so I added app.disableHardwareAcceleration() to runApp in src/main/index.js

It's probably not ideal for less powerful cpus, but at least it works (fedora kde wayland)

JoshuaMacklin commented 1 month ago

Temporary Fix:

For those on Wayland using the Flatpak version, make sure to use flatseal to turn off the X11 Socket, and Turn on the Wayland socket. As FreeTube's flatpak currently defaults to X11 even if you use a wayland system.

I did this on a second system that was having this issue and this resolved it.

MininuxDev commented 1 month ago

Oh that's even better

Weirdly on kde, /app/bin/run.sh doesn't detect that i'm on wayland, the [ -e "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}" ] condition is false. So i had to manually add the flag --ozone-platform-hint=auto when running freetube. Still an easier workaround that recompiling

efb4f5ff-1298-471a-8973-3d47447115dc commented 1 month ago

Does this issue still persist for you on v0.21.0?

fernandobom92 commented 1 month ago

I am facing this same issue here, I am running:

Is stops playing the music If I minimize the FreeTube window or place another window over it.

aidzm commented 1 month ago

I am facing this same issue here, I am running:

  • Fedora OS 43.9 (Wayland)
  • FreeTube v0.21.0 Beta (Flatpak Version)

Is stops playing the music If I minimize the FreeTube window or place another window over it.

What Fedora OS 43.9? Fedora 40 is the current release. Do you mean the GNOME version? Even then the current release is GNOME 46 iirc.

fadri14 commented 1 month ago

Hello, I’m on arch linux with wayland, I just updated to v0.21.0 Beta. I confirm that the problem persists, namely, the music stops when the application is no longer displayed on the screen. I downloaded the application from the AUR.

fernandobom92 commented 1 month ago

I am facing this same issue here, I am running:

  • Fedora OS 43.9 (Wayland)
  • FreeTube v0.21.0 Beta (Flatpak Version)

Is stops playing the music If I minimize the FreeTube window or place another window over it.

What Fedora OS 43.9? Fedora 40 is the current release. Do you mean the GNOME version? Even then the current release is GNOME 46 iirc.

Hi, I am sorry. My Fedora version is 40 and the Gnome version is 43.9 Wayland.

fernandobom92 commented 1 month ago

Temporary Fix:

For those on Wayland using the Flatpak version, make sure to use flatseal to turn off the X11 Socket, and Turn on the Wayland socket. As FreeTube's flatpak currently defaults to X11 even if you use a wayland system.

I did this on a second system that was having this issue and this resolved it.

Could you please explain this process a little more?

fadri14 commented 1 month ago

@fernandobom92 You must install flatseal with this command: flatpak install flathub com.github.tchx84.Flatseal It is a graphical application that allows you to manage permissions and other flatpaks applications. So once installed, just launch it and go to the freetube settings. Then just uncheck x11 and check wayland

ghost commented 1 month ago

The same thing happens here on Ubuntu 24.04, it stops after a while, over and over again. Downloaded from the Ubuntu App Center.

fernandobom92 commented 1 month ago

@fernandobom92 You must install flatseal with this command: flatpak install flathub com.github.tchx84.Flatseal It is a graphical application that allows you to manage permissions and other flatpaks applications. So once installed, just launch it and go to the freetube settings. Then just uncheck x11 and check wayland

Thank you my friend, I will do that!

gianmarcogg03 commented 1 month ago

@fernandobom92 You must install flatseal with this command: flatpak install flathub com.github.tchx84.Flatseal It is a graphical application that allows you to manage permissions and other flatpaks applications. So once installed, just launch it and go to the freetube settings. Then just uncheck x11 and check wayland

I'm on Fedora KDE 40, if I do this the application won't start, running it from the terminal says Missing X server or $DISPLAY.

fadri14 commented 1 month ago

@gianmarcogg03 Do you start your session well with wayland. Maybe activate both at the same time, personally it works.

gianmarcogg03 commented 1 month ago

Do you start your session well with wayland.

You mean my desktop? It's Plasma 6.1 so it is Wayland.

Maybe activate both at the same time, personally it works.

The application starts but the player pause problem isn't solved, likely because it's still using X11 since it has access to it.

fadri14 commented 1 month ago

Sorry I don’t know how to help you.

gianmarcogg03 commented 1 month ago

I just found a solution myself: leave only the Wayland socket on and add an environment variable called ELECTRON_OZONE_PLATFORM_HINT and set it to auto. The player keeps going just fine now.

gianmarcogg03 commented 1 month ago

I just found a solution myself: leave only the Wayland socket on and add an environment variable called ELECTRON_OZONE_PLATFORM_HINT and set it to auto. The player keeps going just fine now.

Found a new problem: now when I want to fullscreen a video, FreeTube crashes.

efb4f5ff-1298-471a-8973-3d47447115dc commented 1 month ago

I just found a solution myself: leave only the Wayland socket on and add an environment variable called ELECTRON_OZONE_PLATFORM_HINT and set it to auto. The player keeps going just fine now.

Found a new problem: now when I want to fullscreen a video, FreeTube crashes.

Same underlying issue as https://github.com/FreeTubeApp/FreeTube/issues/5304

mohuddle commented 4 weeks ago

Temporary Fix:

For those on Wayland using the Flatpak version, make sure to use flatseal to turn off the X11 Socket, and Turn on the Wayland socket. As FreeTube's flatpak currently defaults to X11 even if you use a wayland system.

I did this on a second system that was having this issue and this resolved it.

This fixed it for me. Installed flatseal with-- flatpak install flathub com.github.tchx84.Flatseal

It's not perfect, though. Mouse is incredibly small when in the window. And in full-screen mode, it doesn't quite get the window right. Neither are show stoppers and much prefer having FT being able to play in the background.

sameersharma2006 commented 3 days ago

Snap maintainer here, I have released the fix for the snap package. The fix involves setting a default env. variable of ELECTRON_OZONE_PLATFORM_HINT to auto, by default it sets that to x11.

The fix will be pushed to stable channel soon. See: https://bugs.launchpad.net/freetube/+bug/2074286 & https://git.launchpad.net/freetube/commit/?h=main&id=dcf47ae9fd19976df6273fe8e5a826a66b059dbd

Tested, it does solve the problem in my use-case, any queries & issues regarding snap version are welcome at: https://bugs.launchpad.net/freetube