mozilla-mobile / firefox-ios

Firefox for iOS
Mozilla Public License 2.0
12.12k stars 2.89k forks source link

Synced tabs from web apps like YouTube do not immediately reflect current URL #20904

Open data-sync-user opened 1 month ago

data-sync-user commented 1 month ago

The Bug: On mobile, go to YouTube, browse to a video, and then sync your tabs. You will just see YouTube (home) on desktop, not the direct video link.

Priority of this is probably low… it will eventually resolve. If you swap tabs around and come back to that tab and then sync again, chances are the app has properly saved the URL and when you re-sync, you’ll see the exact YouTube video in your desktop synced tabs.

Very likely has a similar root cause to this bug: https://mozilla-hub.atlassian.net/browse/FXIOS-7127

Tip: Use can this site instead of YouTube while working on a fix… (https://stuff.overengineer.dev/mozilla/testcases/pushstate-nav/0.html ) from https://github.com/mozilla-mobile/firefox-ios/issues/15837#issuecomment-2162552585

Reproduce:

1) In the app, open a new tab, navigate to YouTube, and then tap a top video.

!Screenshot 2024-07-03 at 4.00.10 PM.png|width=517,height=972,alt="Screenshot 2024-07-03 at 4.00.10 PM.png"!

2) Open settings and sync your tabs.

3) Go to the desktop browser and sync your tabs. You will see YouTube home page, not your current video (bug):

!Screenshot 2024-07-03 at 4.00.22 PM.png|width=369,height=188,alt="Screenshot 2024-07-03 at 4.00.22 PM.png"!

4) If you play around in the app for a bit, (e.g. switching tabs), eventually the tab state seems to save properly. If you re-sync your tabs, you’ll eventually see the correct video link on the desktop, as expected:

!Screenshot 2024-07-03 at 4.01.03 PM.png|width=522,height=270,alt="Screenshot 2024-07-03 at 4.01.03 PM.png"!

┆Issue is synchronized with this Jira Bug

data-sync-user commented 1 month ago

➤ Norberto Andres Furlan commented:

Mark Hammond can you take a look to this? Is this just a timing issue ?

data-sync-user commented 1 month ago

➤ Mark Hammond commented:

I suspect this is similar to https://bugzilla.mozilla.org/show_bug.cgi?id=1792698 ( https://bugzilla.mozilla.org/show_bug.cgi?id=1792698|smart-link ) - basically, youtube uses the history.pushState() API to navigate between videos, and depending on how you are listening for tab changes, you may miss these - meaning you may not be telling the tab sync component about the new URL because the navigation was missed. Does that seem likely/possible?

data-sync-user commented 1 month ago

➤ ih-codes commented:

After working on https://mozilla-hub.atlassian.net/browse/FXIOS-7127 ( https://mozilla-hub.atlassian.net/browse/FXIOS-7127|smart-link ), I suspect it’s definitely possible something like that could be happening. I had to fix an asynchronous issues/race condition with when the tab’s session state was being saved. I just happened to check if the same issue occurred with syncing, which is why I noticed this bug.

data-sync-user commented 1 month ago

➤ Mark Hammond commented:

I’m getting out of my comfort zone here, but I don’t think it is a race, it’s simply not noticing the unusual style of navigation. Daniella’s experience from that issue is probably explained by the foregrounding of the app asking for the current URL, which would be correct - it’s just that due to the pushState mechanism you don’t know the URL has changed. I suspect that fixing that linked issue will also fix this - as soon as the browser actually notices the URL change I expect it will automagically tell sync about the new url.