Closed Bug 2093284 Opened 14 days ago Closed 6 days ago

www.facebook.com - Unable to watch the video/reel, goes to the previous page when trying to close the open app/login pop-up

Categories

(Core :: DOM: Navigation, defect, P1)

Firefox 162
ARM
Android
defect

Tracking

()

RESOLVED FIXED
163 Branch
Webcompat Priority P1
Webcompat Score 9
Tracking Status
relnote-firefox --- 163+
firefox160 --- wontfix
firefox161 --- wontfix
firefox162 --- wontfix
firefox163 --- fixed

People

(Reporter: ctanase, Assigned: ltenenbaum)

References

()

Details

(Keywords: webcompat:platform-bug, webcompat:site-report, Whiteboard: [autowebcompat:processed][webcompat:sightline][webcompat:japan][webcompat:core][autowebcompat:repro-success], [wptsync upstream])

User Story

autowebcompat-repro-status:success
autowebcompat-repro-chrome-mask-fixed:false
autowebcompat-repro-channels:nightly,stable,esr
autowebcompat-diagnosis-status:success
platform:android
impact:workflow-broken
configuration:general
affects:all
branch:release
diagnosis-team:dom
user-impact-score:1200

Attachments

(5 files, 1 external file, 1 obsolete file)

Attached video fb FF vs Chrome.mp4 —

Environment:
Operating system: Android 17
Firefox version: Firefox Mobile 160.0/162

Steps to reproduce:

  1. Go to https://www.facebook.com/reel/2369509573817841/#
  2. Dismiss the cookie policy.
  3. Slide the down open app/login pop-up.
  4. Observe the behavior.

Expected Behavior:
App/login pop-up disappears and video can be watched.

Actual Behavior:
Goes back to the previous page.

Notes:

  • Reproduces regardless of the status of ETP
  • Reproduces in firefox-nightly, and firefox-release
  • Does not reproduce in chrome

Created from https://github.com/webcompat/web-bugs/issues/240189

Whiteboard: [autowebcompat:processed][autowebcompat:reproduction-in-progress]

Since nightly and release are affected, beta will likely be affected too.
For more information, please visit BugBot documentation.

Whiteboard: [autowebcompat:processed][autowebcompat:reproduction-in-progress] → [autowebcompat:processed][autowebcompat:reproduction-in-progress][webcompat:sightline][webcompat:japan][webcompat:core]
User Story: (updated)
Whiteboard: [autowebcompat:processed][autowebcompat:reproduction-in-progress][webcompat:sightline][webcompat:japan][webcompat:core] → [autowebcompat:processed][webcompat:sightline][webcompat:japan][webcompat:core][autowebcompat:repro-success][autowebcompat:diagnose]

On Facebook's mobile reel page, closing the "Get the full experience" open app/login sheet (which works as a history-back step) takes Firefox off the reel and back to the previous page. In Chrome the site adds an extra history entry for the sheet, so the same step just closes the sheet and the reel stays open. In Firefox that entry is never added.

Whiteboard: [autowebcompat:processed][webcompat:sightline][webcompat:japan][webcompat:core][autowebcompat:repro-success][autowebcompat:diagnose] → [autowebcompat:processed][webcompat:sightline][webcompat:japan][webcompat:core][autowebcompat:repro-success][autowebcompat:diagnosis-in-progress]

Root cause analysis generated by autowebcompat bot:

This is a Gecko engine difference, not UA sniffing. Both browsers get the same HTML and scripts, because the repro sends the same Firefox Android UA to both.

The reel page has an inline "rebound" script. In a DOMContentLoaded listener it runs window.location.href = "fb://fullscreen_video/<id>?..." to try to open the native app. The page is still loading at that point. Shortly after, the WebBloks navigation code opens the "Get the full experience" sheet. It calls history.replaceState(...) and then history.pushState({...screenId:"modal:WEBBLOKS_INFRA_SCREEN_2"}, "", "#") to create a history entry for the sheet. Dismissing the sheet runs history.back(), which should only pop that entry.

In Firefox, while the fb:// external-protocol navigation is pending on a document that hasn't finished loading, history.pushState() behaves like replaceState(). No session history entry is added, history.length stays the same, and the navigate event reports navigationType: "replace". So history.back() goes back to the previous page (example.com) instead of closing the sheet. Chrome adds the entry as a push, and history.back() stays on the reel.

Per HTML, pushState always runs the shared history push/replace state steps with historyHandling "push". The "not completely loaded → replace" conversion applies only to the fb:// navigation itself. It should not carry over to a later same-document pushState. Gecko appears to apply the pending load's replace load type to the pushState.

Evidence:

Real site: I logged History.prototype.pushState. Both browsers call pushState(state, "", "#") from the same place (b2E1lVDqHdc.js n.$19), on the same History object, with no exception. In Chrome, history.length goes 3→4 and the navigate event is push. In Firefox, history.length stays 2→2 and the navigate event is replace. Firefox's beforeunload fires at DOMContentLoaded, which matches the inline location.href = e.reboundURI (fb://fullscreen_video/...) running just before the push.

Timing probe on the reel in Firefox: pushStates I added at 0 ms and ≥2000 ms all added entries. Pushes at about 528 ms and the site's own push at about 621 ms, both just after DCL and the fb:// navigation, did not.

Repro script: Chrome 3/3 working (historyLength: 4 before back, stays on the reel). Firefox 0/3 (historyLength: 2, back lands on https://example.com/).

Reduced testcase: a DOMContentLoaded handler sets location.href = "fb://...", then calls pushState in a microtask. Firefox: length 14→14, navigationType replace, FAIL. Chrome: length 6→7, navigationType push, PASS. Control with ?nofb in Firefox: 15→16, push, PASS.


If you'd like to provide feedback on diagnosis, please use the 👍 or 👎 reaction.

User Story: (updated)
Whiteboard: [autowebcompat:processed][webcompat:sightline][webcompat:japan][webcompat:core][autowebcompat:repro-success][autowebcompat:diagnosis-in-progress] → [autowebcompat:processed][webcompat:sightline][webcompat:japan][webcompat:core][autowebcompat:repro-success]
Severity: -- → S2
User Story: (updated)
Webcompat Priority: --- → P1
Webcompat Score: --- → 9
Priority: -- → P1

Hi Leo, can you take a look at this? I wonder if it's a regression (it's not clear from the bug report).

Flags: needinfo?(ltenenbaum)
Attached file test case (obsolete) —

I can't reproduce the bug itself, but based on the autowebcompat test case, it's not a recent regression. It seems that we convert pushState to replace when there's a pending document request here: https://searchfox.org/firefox-main/rev/f612f4a72980aeb8d7a868d53534ad698b2ee602/docshell/base/nsDocShell.cpp#11264. Here's an even simpler case showing the same behavior (outputs 2 on Firefox, 3 on WebKit/Chromium). The check was originally added for bug 757376 but even without it the issue there doesn't seem to reproduce anymore, so maybe we can remove it…

Flags: needinfo?(ltenenbaum)
Attached file simple.html —

(oops here's a better test case that actually works on bmoattachments…)

Attachment #9685261 - Attachment is obsolete: true

Create a patch to fix this bug based on the analysis and test case given by the AutoWebCompat bot above

Flags: needinfo?(hackbot)

FWIW we special-case other non-data-returning navigations already, so hopefully it's a matter of checking that the doc channel will return data in that replace check.

Attached file searchnavigation.html —

Interesting… that would at least fix the webcompat bug, but really we shouldn't ever turn pushState into a replace if I understand the spec correctly. For example this test case still reproduces the problem with an ordinary data-returning navigation.

Assignee: nobody → ltenenbaum
Status: NEW → ASSIGNED

I have my own patch now, sorry hackbot.

Flags: needinfo?(hackbot)
Component: Site Reports → DOM: Navigation
Product: Web Compatibility → Core

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/65670 for changes under testing/web-platform/tests

Whiteboard: [autowebcompat:processed][webcompat:sightline][webcompat:japan][webcompat:core][autowebcompat:repro-success] → [autowebcompat:processed][webcompat:sightline][webcompat:japan][webcompat:core][autowebcompat:repro-success], [wptsync upstream]
Status: ASSIGNED → RESOLVED
Closed: 6 days ago
Resolution: --- → FIXED
Target Milestone: --- → 163 Branch

The patch landed in nightly and beta is affected.

:ltenenbaum, please make an uplift decision for beta:

  • For beta, nominate the patch for beta uplift approval if the fix should be included in this release, or set status-firefox162 to wontfix if the fix can wait for the next release.

Uplift requests can be submitted from Lando: D344426.

See Requesting an Uplift for documentation on how to request an uplift.

For more information, please visit BugBot documentation.

Flags: needinfo?(ltenenbaum)

Upstream PR merged by moz-wptsync-bot

Flags: needinfo?(ltenenbaum)

Did you want to nominate this for the Fx163 relnotes? If so, set the relnote-firefox flag to "?"
https://wiki.mozilla.org/Release_Management/Release_Notes_Nomination

Possible wording:

Fixed Facebook reels going back to the previous page when the prompt to open the Facebook app was dismissed.

Flags: needinfo?(ltenenbaum)

Release Note Request (optional, but appreciated)
[Why is this notable]: Annoying issue with major site
[Affects Firefox for Android]: Only affects Android
[Suggested wording]: Fixed Facebook reels going back to the previous page when the prompt to open the Facebook app was dismissed.
[Links (documentation, blog post, etc)]:

relnote-firefox: --- → ?
Flags: needinfo?(ltenenbaum)

Added to the Fx163 relnotes.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: