Closed Bug 1923899 Opened 15 days ago Closed 10 days ago

Retrying commands can fail if currentWindowGlobal is null

Categories

(Remote Protocol :: WebDriver BiDi, defect, P3)

defect
Points:
2

Tracking

(firefox133 fixed)

RESOLVED FIXED
133 Branch
Tracking Status
firefox133 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

(Blocks 1 open bug)

Details

(Whiteboard: [webdriver:m13])

Attachments

(1 file)

We fixed a first issue related to a null currentWindowGlobal in Bug 1921756.

But we still have other locations in the code which access currentWindowGlobal without performing any prior check and it still can fail in puppeteer. Example failure: https://github.com/puppeteer/puppeteer/actions/runs/11269966405/job/31339679526#step:9:456

ProtocolError: Protocol error (browsingContext.create): unknown error TypeError: can't access property "getActor", webProgress.browsingContext.currentWindowGlobal is null _sendCommandToBrowsingContext@chrome://remote/content/shared/messagehandler/transports/RootTransport.sys.mjs:127:9
forwardCommand@chrome://remote/content/shared/messagehandler/transports/RootTransport.sys.mjs:71:19
forwardCommand@chrome://remote/content/shared/messagehandler/RootMessageHandler.sys.mjs:162:36
#waitForVisibilityChange@chrome://remote/content/webdriver-bidi/modules/root/browsingContext.sys.mjs:2006:32
create@chrome://remote/content/webdriver-bidi/modules/root/browsingContext.sys.mjs:623:73
handleCommand@chrome://remote/content/shared/messagehandler/MessageHandler.sys.mjs:257:33
execute@chrome://remote/content/shared/webdriver/Session.sys.mjs:390:32
onPacket@chrome://remote/content/webdriver-bidi/WebDriverBiDiConnection.sys.mjs:228:37
onMessage@chrome://remote/content/server/WebSocketTransport.sys.mjs:127:18
handleEvent@chrome://remote/content/server/WebSocketTransport.sys.mjs:109:14

This is related to the internal command _awaitVisibilityState used at https://searchfox.org/mozilla-central/rev/9f49f28c3b7f53b1a1f47350ed38437d113d1aa6/remote/webdriver-bidi/modules/root/browsingContext.sys.mjs#2005-2018

#waitForVisibilityChange(browsingContext) {
  return this.messageHandler.forwardCommand({
    moduleName: "browsingContext",
    commandName: "_awaitVisibilityState",
    destination: {
      type: lazy.WindowGlobalMessageHandler.type,
      id: browsingContext.id,
    },
    params: {
      value: "hidden",
    },
    retryOnAbort: true,
  });
}

This command always used retryOnAbort, so it's unclear why this is recently spiking on Puppeteer's CI, apparently only on Windows.
We already had discussions about what should be done in such cases for Marionette (which uses a similar retry pattern) at https://bugzilla.mozilla.org/show_bug.cgi?id=1662808#c4 but in the end we didn't change anything as it seemed very low frequency.

When attempting to send commands on a very early browsing context, the command might fail
due to a missing currentWindowGlobal.
This patch adds a helper to wait for the currentWindowGlobal property to be set and uses it from
RootTransport in order to avoid this issue.
A browser mochitest is added to cover this scenario.

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Severity: -- → S3
Points: --- → 2
Priority: -- → P3
Whiteboard: [webdriver:m13]
Pushed by jdescottes@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/879b49c5132b [bidi] Wait for currentWindowGlobal when sending commands to window global message handlers r=webdriver-reviewers,Sasha
Status: ASSIGNED → RESOLVED
Closed: 10 days ago
Resolution: --- → FIXED
Target Milestone: --- → 133 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: