Closed Bug 1886083 Opened 2 months ago Closed 2 months ago

Video goes to picture-in-picture then disappears when you tap fullscreen

Categories

(Fenix :: Media, defect, P2)

Firefox 123
All
Android

Tracking

(firefox124 wontfix, firefox125 verified, firefox126 verified)

VERIFIED FIXED
126 Branch
Tracking Status
firefox124 --- wontfix
firefox125 --- verified
firefox126 --- verified

People

(Reporter: brianpeiris, Assigned: jackyzy823)

References

Details

(Whiteboard: [ux-fun-2024] [qa-triaged] [fxdroid] [group4] [s2-list25?] )

Attachments

(3 files, 1 obsolete file)

Steps to reproduce:

Steps to repro:

  1. Open Firefox and visit a page with a video, like https://videojs.github.io/autoplay-tests/plain/simple.html
  2. Switch to any other app, like the Play Store
  3. Switch back to Firefox.
  4. Play the video.
  5. Tap the fullscreen button.

Actual results:

Firefox switches to Android's picture-in-picture mode briefly, before disappearing entirely, but the video continues to play in the background.

I've reproduced this on a fresh install of Firefox Nightly (125.0a1) on my Google Pixel Tablet running Android 14. I originally noticed the issue on Firefox Stable. It does not occur with other video-playing apps like YouTube or Google Chrome.

Expected results:

The video should just play in fullscreen.

Attached video rec.mp4

I've attached a screen recording of the issue.

See Also: → 1848266

Product here could also be GeckoView, just like in 1848266 . You might want to change it

Hi,
I couldn't reproduce the described issue.
Picture in Picture works as expected (with a second of pause on Pixel before it's activated).
I've used a device close to yours: Google Pixel 7 (Android 14).
Also tried reproducing it on a Samsung Galaxy S23 Ultra (Android 14).
Could you reproduce it on the latest Nightly as well? You could also try on the latest RC (124.0) or latest Beta (125.0b2), or if you don't have anything to loose, you could even try to perform a clear data on the 123 version you reproduced on.
Thank you!

Whiteboard: [qa-triaged]

(In reply to Lorand Janos from comment #3)

Hello. I'm still able to reproduce this. To rule out my particular Pixel Tablet, I reproduced it on my Galaxy S21 phone as well, running Android 14.
On the S21, I can reproduce it with a fresh install of Firefox Stable (123.1.0), Nightly (126.0a1), and Beta (124.0b9) -- all installed from the Play Store.

Please note that the issue is with the fullscreen behavior, not the picture-in-picture behavior. Specifically, when I follow the steps, Firefox incorrectly goes into picture-in-picture mode, and then immediately hides the video entirely, when it should just fullscreen the video.

Also note that this only happens the very first time you attempt to fullscreen a video after starting Firefox after quitting the app. Subsequent fullscreen attempts work correctly.

I think I've figured out the key factor here. I'm only able to reproduce this if I disallow or block notifications from Firefox. It seems Firefox attempts to prompt for notifications permissions, when it goes fullscreen. If you block notifications, I think it fails to prompt for notifications permissions, which causes this bug.

I also used mozregression to narrow down the build that caused this issue. I don't think mozregression allows you to bisect to a specific commit for android builds, but it did narrow it down to the nightly released on 2023-09-06.

Here are the good and bad APKs and version details:

Good - https://archive.mozilla.org/pub/fenix/nightly/2023/09/2023-09-05-16-01-49-fenix-119.0a1-android-arm64-v8a/fenix-119.0a1.multi.android-arm64-v8a.apk

119.0a1 (Build #2015972419), 2d460b0327+
GV: 119.0a1-20230905094754
AS: 119.20230903050308
2023-09-05T16:06:38.095648758

Bad - https://archive.mozilla.org/pub/fenix/nightly/2023/09/2023-09-06-16-04-51-fenix-119.0a1-android-arm64-v8a/fenix-119.0a1.multi.android-arm64-v8a.apk

119.0a1 (Build #2015972611), e45a12029e+
GV: 119.0a1-20230906091315
AS: 119.20230906050317
2023-09-06T16:08:42.847241023

Thanks for your very valuable investigation Brian Peiris!
I could actually reproduce the bug once in Nightly following your instructions, and then I couldn't any more, neither in Nightly, neither in release. Even after removing the app's data.

Do you know a way of reproducing the bug again? Does closing the app and opening it again work for you all the time?

Thanks. Yes, I can reproduce this consistently with the following steps, using the current Nightly from the Play Store:

  1. To start from a clean slate, uninstall Nightly, or Force Stop and Clear all data.
  2. Open Nightly and choose "Not now" for all the initial setup prompts
  3. Visit https://videojs.github.io/autoplay-tests/plain/simple.html
  4. Switch to the Play Store (or any other app)
  5. Switch back to Nightly
  6. Play the video
  7. Fullscreen the video
  8. Notice at this point it attempts to go into fullscreen, but also shows a prompt to allow notification permissions, which causes the video to go into picture-in-picture (PiP)
  9. Tap "Don't allow" in the notification permission prompt
  10. Notice the PiP video disappears at this point, but its audio is still playing in the background
  11. Open Nightly from its app icon
  12. Notice the notification permission prompt appears again.
  13. Tap "Don't allow" again
  14. While the video is still playing, switch back to the Play Store
  15. Switch back to Nightly
  16. Attempt to fullscreen the video
  17. Notice the video fails to fullscreen, and even the PiP disappears
  18. Open Nightly from its app icon
  19. While the video is still playing, switch back to the Play Store
  20. Switch back to Nightly from its app icon

At this point you can repeat steps 16-20 to reproduce the issue consistently, as long as the video is still playing. The important step seems to be switching to another app, and then back to Nightly. You may also notice that the video starts to get choppy, which seems to be the performance issue mentioned in bug 1848266

I can 100% reproduce the bug now, thanks a lot!

I realise I was switching from Fenix to the Play Store using the "Running apps" list and it doesn't reproduce the bug.

Going back to the "Home" screen and launching the app from there reproduces the bug all the time.
It will be a lot easier to work on this bug now that we know how to reproduce it. Thanks a lot for your help on that!

Glad to hear it! Thanks for confirming the issue.

Hi Brian Peiris,

Your investigation and STR is marvelous .

But i think the bisection might not be accurate. I've tested and uploaded a video which demonstrates the same issue , but it was started at least from 9 months ago on 115.0b5 .

Some guess:

  1. What PiP is activated? https://searchfox.org/mozilla-central/rev/47a0a01e1f7ad0451c6ba6c790d5c6855df512c1/mobile/android/android-components/components/feature/session/src/main/java/mozilla/components/feature/session/PictureInPictureFeature.kt#49
    Because it was trigger by onHomePressed

  2. Why onHomePressed activated
    https://searchfox.org/mozilla-central/rev/47a0a01e1f7ad0451c6ba6c790d5c6855df512c1/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt#1680
    https://searchfox.org/mozilla-central/rev/47a0a01e1f7ad0451c6ba6c790d5c6855df512c1/mobile/android/focus-android/app/src/main/java/org/mozilla/focus/activity/MainActivity.kt#202
    Because onUserLeaveHint is called

  3. Why onUserLeaveHint is called?
    handleMediaPlaying calling updateNotification then notificationsDelegate.notify and when we haven't granted notification permission, the android system will show a dialog ask user to allow or not.
    I guess this dialog will trigger onUserLeaveHint
    https://searchfox.org/mozilla-central/rev/47a0a01e1f7ad0451c6ba6c790d5c6855df512c1/mobile/android/android-components/components/feature/media/src/main/java/mozilla/components/feature/media/service/MediaSessionServiceDelegate.kt#151,185
    https://searchfox.org/mozilla-central/rev/47a0a01e1f7ad0451c6ba6c790d5c6855df512c1/mobile/android/android-components/components/support/base/src/main/java/mozilla/components/support/base/android/NotificationsDelegate.kt#130,154


Update:
A stack overflow answer also show the problem : https://stackoverflow.com/a/67587797


I'm not sure why it doesn't happens if we skip step 4,5 ( just directly play and fullscreen.)

Duplicate of this bug: 1838541
Duplicate of this bug: 1848266
Whiteboard: [qa-triaged] → [qa-triaged][fxdroid][[group4]

I'm not sure why it doesn't happens if we skip step 4,5 ( just directly play and fullscreen.)

Ok, i add some log, found that , In just directly play and fullscreen. situation ,the enterPipModeCompat is also called , but maybe failed to enter PIP mode.

More clearly

  1. enterPipModeForO (aka activity.enterPictureInPictureMode(PictureInPictureParams.Builder().build())) return true with step 4,5
  2. enterPipModeForO (aka activity.enterPictureInPictureMode(PictureInPictureParams.Builder().build())) return false when directly playing and fullscreen
Assignee: nobody → jackyzy823
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #9393421 - Attachment is obsolete: true
Severity: -- → S2
Priority: -- → P2
Whiteboard: [qa-triaged][fxdroid][[group4] → [qa-triaged][fxdroid][[group4][s2-list25?]
Pushed by tthibaud@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e6928f8a72bb
Don't call onHomePressed when notification permission prompt is shown. r=android-reviewers,tthibaud
Whiteboard: [qa-triaged][fxdroid][[group4][s2-list25?] → [ux-fundamental]
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 126 Branch

Thanks for the fix!

Flags: qe-verify+

The patch landed in nightly and beta is affected.
:jackyzy823, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox125 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(jackyzy823)

I don't think this is important to uplift. (Feel free to change this)

Flags: needinfo?(jackyzy823)

Verified as fixed on the latest Nightly (126.0a1 from 2024-04-05).
The video is played on full screen as expected.
Device used: Samsung Galaxy S23 Ultra (Android 14).
Marking as verified for 126.

Flags: qe-verify+
Whiteboard: [ux-fundamental] → [ux-fundamental] [qa-triaged][fxdroid][[group4][s2-list25?]
Whiteboard: [ux-fundamental] [qa-triaged][fxdroid][[group4][s2-list25?] → [ux-fun-2024] [qa-triaged] [fxdroid] [group4] [s2-list25?]
Duplicate of this bug: 1885081
See Also: → 1890726
Component: General → Media
See Also: → 1890728

Comment on attachment 9398144 [details] [review]
[mozilla-mobile/firefox-android] Bug 1886083 - Don't call onHomePressed when notification permission prompt is shown (#6082)

Beta/Release Uplift Approval Request

  • User impact if declined: Users can still experience the following bug:
    Video goes to picture-in-picture then disappears when you tap fullscreen.
    It's been a hight-frequency complain from users on the PlayStore
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Risk is low because the patch as already has already in Nightly for almost 3 weeks
  • String changes made/needed:
  • Is Android affected?: Yes
Attachment #9398144 - Flags: approval-mozilla-release?

Comment on attachment 9398144 [details] [review]
[mozilla-mobile/firefox-android] Bug 1886083 - Don't call onHomePressed when notification permission prompt is shown (#6082)

Approved for 125.3.0

Attachment #9398144 - Flags: approval-mozilla-release? → approval-mozilla-release+

Authored by https://github.com/jackyzy823
https://github.com/mozilla-mobile/firefox-android/commit/36588b4d0dc4f4f897324dac43c04eb8317b7d8d
[releases_v125] Bug 1886083 - Don't call onHomePressed when notification permission prompt is shown. r=#android-reviewers

Verified as fixed on the latest RC 125.3 build 1 with Google Pixel 8 Pro (Android 14).

Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: