-
-
Notifications
You must be signed in to change notification settings - Fork 544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix playerAutopauseWhenSwitchingTabs when minimizing browser #2386
Conversation
Chrome sends two blur events and breaks restoring play
Even found a bug about this #1103 caused by chrome.windows.onFocusChanged |
what about both working together? (universal question)
looking forward! |
Patch can go in as is for now. This will fix double blur events on window switch. youtube/js&css/web-accessible/core.js Lines 379 to 388 in 2e850c8
or youtube/js&css/web-accessible/functions.js Lines 287 to 291 in 2e850c8
and Lines 208 to 220 in 85bf124
so only playerQualityWithoutFocus runs on Window switch. |
Chromesends two blur events and breaks restoring play EDIT: ... and this patchdoesntdidnt fix this :D It does now!For a hot minute I though above patch fixed this, then that maybe this #2375 did it as I couldnt reproduce the bug anymore, but NO! I was missing the crucial piece. Problem happens only with more than one Browser window! Its not Chrome sending two blur events, its still our background.js :] :|
We handle normal tab switching
youtube/background.js
Line 191 in 85bf124
but also send blur on Window minimize
youtube/background.js
Line 208 in 85bf124
without check if the window being minimized is the Active one.
I was triggering this bug by using undocked DevTools console = second Chrome window. Now that I understand it I can reproduce it using Chrome with two normal windows. Minimize one after another and two blur events are send to our Tab setting this.played_before_blur first to True just to overwrite it with false on second one.
Two ways to fix this. lazy one is to keep state of focus in ImprovedTube, proper to track focus state in background.js and make sure we only send one blur/focus message. Second option is implemented in 9e76934