Bug 1617675 Comment 1 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

(In reply to Christian Sadilek [:csadilek] from comment #0)
> We're seeing intermittent failures of web-ext run caused by:
> 
> ```
> o: Remote Firefox: listTabs() error: unknownError: can't access property "selectedBrowser", aWindow.BrowserApp is undefined
> ...
> ```

As I mentioned to Christian, this error is very likely thrown from here: https://searchfox.org/mozilla-central/rev/96f1457323cc598a36f5701f8e67aedaf97acfcf/mobile/android/modules/dbg-browser-actors.js#82

Looking at the blame for that line, it looks it is coming directly from Fennec (introduced by Bug 909782), which makes sense given that `BrowserApp` was originally part of the Fennec internals. 

In GeckoView that `BrowserApp` global is lazily created here from `GeckoViewTab.jsm`:
- https://searchfox.org/mozilla-central/rev/96f1457323cc598a36f5701f8e67aedaf97acfcf/mobile/android/modules/geckoview/GeckoViewTab.jsm#74

and so my guess is that web-ext is triggering a race between the "remote debugging server calling listTabs" (because `web-ext run` is quickly connecting to the RemoteDebuggingServer are soon as it is reachable) and "BrowserApp global being created by GeckoViewTab.jsm".

This issue looks something that we should fix in `dbg-browser-actors.js`, e.g. we could either:

- import `GeckoViewTab.jsm` from  `dbg-browser-actors.js` and then use `BrowserAppShim.getBrowserApp(window)` to get the `BrowserApp` object for a given window (and avoid the race that is likely triggering the error)

- or remove any usage of BrowserApp from it (and replace with a more "GeckoView"-way of implementing those methods)
(In reply to Christian Sadilek [:csadilek] from comment #0)
> We're seeing intermittent failures of web-ext run caused by:
> 
> ```
> o: Remote Firefox: listTabs() error: unknownError: can't access property "selectedBrowser", aWindow.BrowserApp is undefined
> ...
> ```

As I mentioned to Christian, this error is very likely thrown from here: https://searchfox.org/mozilla-central/rev/96f1457323cc598a36f5701f8e67aedaf97acfcf/mobile/android/modules/dbg-browser-actors.js#82

Looking at the blame for that line, it looks it is coming directly from Fennec (introduced by Bug 909782), which makes sense given that `BrowserApp` was originally part of the Fennec internals. 

In GeckoView that `BrowserApp` global is lazily created here from `GeckoViewTab.jsm`:
- https://searchfox.org/mozilla-central/rev/96f1457323cc598a36f5701f8e67aedaf97acfcf/mobile/android/modules/geckoview/GeckoViewTab.jsm#74

and so my guess is that web-ext is triggering a race between the "remote debugging server calling listTabs" (because `web-ext run` is quickly connecting to the RemoteDebuggingServer are soon as it is reachable) and "BrowserApp global being created by GeckoViewTab.jsm".

This issue looks something that we should fix in `dbg-browser-actors.js`, e.g. we could either:

- import `GeckoViewTab.jsm` from  `dbg-browser-actors.js` and then use `BrowserAppShim.getBrowserApp(window)` to get the `BrowserApp` object for a given window (and avoid the race that is likely triggering the error), but it is worth to mention that `BrowserAppShim` doesn't provide a `tabs` property and so [`MobileTabList.prototype._getChildren`](https://searchfox.org/mozilla-central/rev/96f1457323cc598a36f5701f8e67aedaf97acfcf/mobile/android/modules/dbg-browser-actors.js#85-87) would still be broken (it seems to be used [here](https://searchfox.org/mozilla-central/rev/96f1457323cc598a36f5701f8e67aedaf97acfcf/devtools/server/actors/webbrowser.js#269) to iterate over all the tabs).

- or remove any usage of BrowserApp from it (and replace with a more "GeckoView"-way of implementing those methods)

Back to Bug 1617675 Comment 1