Open Bug 1789839 Opened 2 years ago Updated 1 year ago

requestedBrowser.currentURI is null when clicking tab from Tab pickup in Firefox View

Categories

(Firefox :: Firefox View, defect, P3)

defect

Tracking

()

People

(Reporter: niklas, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: steps-wanted, Whiteboard: [fidefe-2022-mr1-firefox-view])

Clicking any of the tabs in the tab pickup section causes JavaScript error: resource:///modules/AsyncTabSwitcher.jsm, line 378: TypeError: can't access property "schemeIs", requestedBrowser.currentURI is null.
The tab opens seemingly normal but we shouldn't be getting an error for this

Severity: -- → S3
Priority: -- → P2

Mike, any idea what's going on in asynctabswitcher here?

Blocks: firefox-view
Flags: needinfo?(mconley)
Whiteboard: [fidefe-2022-mr1-firefox-view]

Hey Niklas, I'm not able to reproduce this in Nightly... are you seeing this consistently? If so, do you have some STR for me?

Flags: needinfo?(mconley) → needinfo?(nbaumgardner)

STR for me:

  1. open Fx View
  2. Click any of the tabs in the Tab pickup section. All 3 of the tabs will throw an error for me.

Result:
The browser console will show an error for TypeError: can't access property "schemeIs", requestedBrowser.currentURI is null

It might be worth noting that I am on Windows 11

Flags: needinfo?(nbaumgardner)

Like Mike I cannot repro. So I guess we need more detailed steps to repro here. Niklas, can you reproduce on a clean profile?

Flags: needinfo?(nbaumgardner)
Keywords: steps-wanted

Yes, I'm able to reproduce on a clean profile. I am able to reproduce and Windows and mac. I haven't tried reproducing on Linux.
The error doesn't occur every time for me. But it does happen at least 1/3 of the time. There must be some race condition that I'm hitting

Flags: needinfo?(nbaumgardner)

(In reply to Niklas Baumgardner [:niklas] from comment #5)

Yes, I'm able to reproduce on a clean profile. I am able to reproduce and Windows and mac. I haven't tried reproducing on Linux.
The error doesn't occur every time for me. But it does happen at least 1/3 of the time. There must be some race condition that I'm hitting

Mike do you have an idea about steps Niklas can use to debug this in the AsyncTabSwitcher to work out what's happening?

Flags: needinfo?(mconley)

I still haven't seen this. Bizarre.

Niklas, one thing you could try to do is set browser.tabs.remote.logSwitchTiming to true to have the AsyncTabSwitcher start emitting logs. Then, if you can reproduce the error, I'd be interested in seeing the logging just before and after the error message.

Flags: needinfo?(mconley) → needinfo?(nbaumgardner)

Here's a log of before and after the error

START
Initial tab is loaded?: true
ATS: 0:VRM(AR)(loaded) 1...3:(unloaded) cached: 0 {requestTab 1(about:blank)}
Loading tab 1(about:blank)
ATS: 0:VM(AR)(loaded) 1:LR(AR)(loading) 2...3:(unloaded) cached: 0 {onLayersReady(1, false)}
Switch to tab 4 - 1(about:blank)
DEBUG: tab switch time = 2
ATS: 0:M(AR)(loaded) 1:VRM(AR)(loaded) 2...3:(unloaded) cached: 0 {/queueUnload}
ATS: 0:(AR)(loaded) 1:VR(AR)(loaded) 2...3:(unloaded) cached: 0 [onPaint(11)] {/MozAfterPaint}
ATS: 0:(AR)(loaded) 1:VR(AR)(loaded) 2...3:(unloaded) cached: 0 [onPaint(01)] {/MozAfterPaint}
ATS: unchanged{/MozAfterPaint} 14
TypeError: can't access property "schemeIs", requestedBrowser.currentURI is null              AsyncTabSwitcher.jsm:378:26
ATS: 0:(AR)(loaded) 1:VR(AR)(loaded) 2...3:(unloaded) cached: 0 {onRemotenessChange(1, true)}
ATS: 0:(AR)(loaded) 1:VRB(AR)(loading) 2...3:(unloaded) cached: 0 [blank(01110),isRemote] {/TabRemotenessChange}
ATS: 0:(AR)(loaded) 1:VRB(AR)(loading) 2...3:(unloaded) cached: 0 {onLayersReady(1, true)}
ATS: 0:(AR)(loaded) 1:VR(AR)(loaded) 2...3:(unloaded) cached: 0 [nonblank(01111),isRemote] {/MozLayerTreeReady}
ATS: 0:(AR)(loaded) 1:VR(AR)(loaded) 2...3:(unloaded) cached: 0 [onPaint(01),nonblank(01101),isRemote] {/MozAfterPaint}
ATS: unchanged{/MozAfterPaint} 3
ATS: 0:(unloading) 1:VR(AR)(loaded) 2...3:(unloaded) cached: 0 {onLayersCleared(0)}
FINISH 
Flags: needinfo?(nbaumgardner)

So looking at this and tracing through the code, the only thing I can think of that might cause this is if somehow we're initiating the tabswitch before the <browser> element for the newly opened tab has had a chance to run its connectedCallback (which runs construct(), which sets up the RemoteWebNavigation, which is the requirement to have currentURI not be null).

How is Firefox View opening up these new tabs? Is it doing anything special for that, or is it like any other link?

Flags: needinfo?(nbaumgardner)

(In reply to Mike Conley (:mconley) (:⚙️) from comment #9)

So looking at this and tracing through the code, the only thing I can think of that might cause this is if somehow we're initiating the tabswitch before the <browser> element for the newly opened tab has had a chance to run its connectedCallback (which runs construct(), which sets up the RemoteWebNavigation, which is the requirement to have currentURI not be null).

How is Firefox View opening up these new tabs? Is it doing anything special for that, or is it like any other link?

Nope, it's just any other link - here's the HTML:

<a class="synced-tab-a" href="https://www.nvaccess.org/download/" target="_blank" data-l10n-id="firefoxview-tabs-list-tab-button" data-l10n-args="{&quot;targetURI&quot;:&quot;https://www.nvaccess.org/download/&quot;}" title="Open https://www.nvaccess.org/download/ in a new tab">
  <div style="background-image: url(&quot;moz-anno:favicon:https://www.nvaccess.org/wp-content/themes/nvaccess2017/img/favicon.png&quot;);" class="favicon"></div>
  <div class="last-active-badge"><span class="dot"></span><span data-l10n-id="firefoxview-pickup-tabs-badge" class="badge-text">Last active</span></div>
  <span class="synced-tab-li-title">NV Access | Download NVDA</span>
  <span title="https://www.nvaccess.org/download/" class="synced-tab-li-url">nvaccess.org</span>
  <span title="Gijs’s Nightly" class="synced-tab-li-device">
    <div class="icon desktop" role="presentation"></div>Gijs’s Nightly
  </span>
  <span class="synced-tab-li-time" data-timestamp="1663151331000">last wk</span>
</a>

(somewhat inaccurate whitespace for readability, but hopefully that makes sense of it)

Is it possible the error is coming from the fxview tab? That is a hidden, pinned tab, which seems more likely to confuse... something.

Flags: needinfo?(nbaumgardner) → needinfo?(mconley)
Priority: P2 → P3

(In reply to :Gijs (he/him) from comment #10)

Is it possible the error is coming from the fxview tab? That is a hidden, pinned tab, which seems more likely to confuse... something.

It's not a pinned tab, but it is hidden, meaning that the tab element (not the browser element) is hidden. It's possible that there's some code somewhere that should handle all tabs but is only looking at visible tabs (e.g. via gBrowser.visibleTabs), or something along these lines. Off-hand I couldn't find anything though...

Blocks: 1797520
No longer blocks: firefox-view

I was working with Niklas on this during the Hawaii All-Hands, and we started to make some inroads. Still pretty mysterious.

I think the only way of truly getting this sorted is with some pretty aggressive logging to (a) confirm that the <browser> we're attempting to access is the one we expect, and (b) figure out why it isn't ready by the time we try to access the currentURI property.

Flags: needinfo?(mconley)

I just looked into this a bit more and what I'm experiencing is that when we call the getter for currentURI, this.webNavigation is null.
The getter for this.webNavigation is here. It returns this._remoteWebNavigation (because the requestedBrowser in AsyncTabSwitch is a remote browser).
this._remoteWebNavigation is set in the construct so I logged the stack in contruct which was

@debugger eval code:1:2
construct@chrome://global/content/elements/browser-custom-element.js:991:26
finishChangeRemoteness@chrome://global/content/elements/browser-custom-element.js:1903:12
getInterfaceProxy/get/<@chrome://global/content/customElements.js:688:35

we are calling construct from finishChangeRemoteness which is called from getInterfaceProxy.

It's odd that when we call requestedBrowser.currentURI in AsyncTabSwitcher, the _remoteWebNavigation is null.

Any new updates on this one?

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