mozilla-mobile / firefox-ios

Firefox for iOS
Mozilla Public License 2.0
12.04k stars 2.87k forks source link

Bug: restoring app with two windows open may cause one of them to load an incorrect URL #19810

Open data-sync-user opened 1 month ago

data-sync-user commented 1 month ago

Potential bug that needs further investigation. I dug into this for several hours but wasn’t able to actually identify the culprit, even after adding breakpoints and debug code to every load()-related method and delegate callback. The issue appears to be a race of some kind because it does not always repro reliably.

Setup/repro for debugging:

  1. Launch app with single window, load website A
  2. Create a 2nd window in split view, load website B
  3. Terminate app from Xcode
  4. Relaunch the app

Result: after relaunching, both windows are restored, but sometimes the selected tab in one of the windows will be incorrectly set to the wrong URL (from the opposite window).


Notes

┆Issue is synchronized with this Jira Task

data-sync-user commented 1 month ago

➤ Matt Reagan commented:

Note: one method that could help with debugging this is to:

  1. Open iPad, create 2 windows in split mode
  2. In code, override crashedLastLaunch to return true
  3. Kill the app in xcode, and re-run

In this flow, each window shows an alert to restore tabs, allowing them to be restored individually. In this flow, the above bug still reproduces (which is interesting) but also means that it may be easier to isolate what exactly is going wrong since the first window can be restored and then the 2nd window examined more closely with all breakpoints enabled etc.

data-sync-user commented 3 weeks ago

➤ Matt Reagan commented:

This should now be fixed by an update which injects a separate tab data store for each window (rather than using a shared instance in the app container).