Closed Bug 1775855 Opened 4 years ago Closed 1 month ago

Intermittent browser/base/content/test/protectionsUI/browser_protectionsUI.js | single tracking bug

Categories

(Firefox :: Protections UI, defect, P3)

defect

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: jmaher, Unassigned)

References

Details

(Keywords: intermittent-failure, intermittent-testcase)

Attachments

(4 external files, 1 obsolete file)

No description provided.

Additional information about this bug failures and frequency patterns can be found by running: ./mach test-info failure-report --bug 1775855

Severity: -- → S4

Update

There have been 34 total failures within the last 7 days:

  • 1 failure on Linux 18.04 x64 WebRender opt
  • 3 failures on Linux 18.04 x64 WebRender Shippable opt
  • 3 failures on OS X 10.15 WebRender Shippable opt
  • 27 failures on OS X 11 WebRender Shippable opt

Recent log: https://treeherder.mozilla.org/logviewer?job_id=437709373&repo=autoland&lineNumber=3857

[task 2023-11-26T17:58:56.733Z] 17:58:56     INFO - TEST-PASS | browser/base/content/test/protectionsUI/browser_protectionsUI.js | recorded etp_toggle_on telemetry event - 
[task 2023-11-26T17:58:56.733Z] 17:58:56     INFO - Leaving test bound testToggleSwitch
[task 2023-11-26T17:58:56.733Z] 17:58:56     INFO - Entering test bound testSettingsButton
[task 2023-11-26T17:58:56.733Z] 17:58:56     INFO - Console message: [JavaScript Warning: "The resource at “http://trackertest.org/” was blocked because content blocking is enabled." {file: "http://tracking.example.org/browser/browser/base/content/test/protectionsUI/trackingPage.html" line: 0}]
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - Console message: [JavaScript Error: "TypeError: can't access property "GetAvailRect", screen is null" {file: "resource:///modules/PanelMultiView.sys.mjs" line: 1197}]
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - _calculateMaxHeight@resource:///modules/PanelMultiView.sys.mjs:1197:5
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - handleEvent@resource:///modules/PanelMultiView.sys.mjs:1267:32
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - EventListener.handleEvent*connect@resource:///modules/PanelMultiView.sys.mjs:415:17
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - openPopup/this._openPopupPromise<@resource:///modules/PanelMultiView.sys.mjs:540:16
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - promise callback*openPopup@resource:///modules/PanelMultiView.sys.mjs:521:55
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - openPopup@resource:///modules/PanelMultiView.sys.mjs:274:47
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - showProtectionsPopup@chrome://browser/content/browser-siteProtections.js:2511:20
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - handleProtectionsButtonEvent@chrome://browser/content/browser-siteProtections.js:1800:10
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - onclick@chrome://browser/content/browser.xhtml:1:21
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - synthesizeMouseAtPoint@chrome://mochikit/content/tests/SimpleTest/EventUtils.js:758:13
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - synthesizeMouse@chrome://mochikit/content/tests/SimpleTest/EventUtils.js:565:10
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - synthesizeMouseAtCenter@chrome://mochikit/content/tests/SimpleTest/EventUtils.js:846:10
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - openProtectionsPanel@chrome://mochitests/content/browser/browser/base/content/test/protectionsUI/head.js:57:16
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - testToggleSwitch@chrome://mochitests/content/browser/browser/base/content/test/protectionsUI/browser_protectionsUI.js:56:9
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - async*handleTask@chrome://mochikit/content/browser-test.js:1138:26
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - _runTaskBasedTest@chrome://mochikit/content/browser-test.js:1210:18
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - async*Tester_execTest@chrome://mochikit/content/browser-test.js:1352:14
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - nextTest/<@chrome://mochikit/content/browser-test.js:1127:14
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - SimpleTest.waitForFocus/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:1058:13
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - 
[task 2023-11-26T17:58:56.734Z] 17:58:56     INFO - Buffered messages finished
[task 2023-11-26T17:58:56.735Z] 17:58:56     INFO - TEST-UNEXPECTED-FAIL | browser/base/content/test/protectionsUI/browser_protectionsUI.js | Test timed out - 
[task 2023-11-26T17:58:56.735Z] 17:58:56     INFO - Not taking screenshot here: see the one that was previously logged
[task 2023-11-26T17:58:56.735Z] 17:58:56     INFO - TEST-UNEXPECTED-FAIL | browser/base/content/test/protectionsUI/browser_protectionsUI.js | Uncaught exception received from previously timed out test bound testSettingsButton - popupshown listener not removed before the end of test

Paul, can you help us assign this to someone?
Thank you.

Flags: needinfo?(pbz)
Whiteboard: [stockwell needswork:owner]

Looking at the failure screenshots for macOS, we don't event seem to be drawing a window? https://firefoxci.taskcluster-artifacts.net/Q2hsWnowRySoHwcUH73ztg/0/public/test_info/mozilla-test-fail-screenshot_7xlog5yc.png

That might also be why GetAvailRect fails in the PanelMultiView code:

[task 2023-12-11T09:02:07.680Z] 09:02:07     INFO - Entering test bound testSettingsButton
[task 2023-12-11T09:02:07.681Z] 09:02:07     INFO - Console message: [JavaScript Warning: "The resource at “http://trackertest.org/” was blocked because content blocking is enabled." {file: "http://tracking.example.org/browser/browser/base/content/test/protectionsUI/trackingPage.html" line: 0}]
[task 2023-12-11T09:02:07.682Z] 09:02:07     INFO - Console message: [JavaScript Error: "TypeError: can't access property "GetAvailRect", screen is null" {file: "resource:///modules/PanelMultiView.sys.mjs" line: 1197}]
[task 2023-12-11T09:02:07.682Z] 09:02:07     INFO - _calculateMaxHeight@resource:///modules/PanelMultiView.sys.mjs:1197:5
[task 2023-12-11T09:02:07.682Z] 09:02:07     INFO - handleEvent@resource:///modules/PanelMultiView.sys.mjs:1267:32
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - EventListener.handleEvent*connect@resource:///modules/PanelMultiView.sys.mjs:415:17
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - openPopup/this._openPopupPromise<@resource:///modules/PanelMultiView.sys.mjs:540:16
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - promise callback*openPopup@resource:///modules/PanelMultiView.sys.mjs:521:55
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - openPopup@resource:///modules/PanelMultiView.sys.mjs:274:47
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - showProtectionsPopup@chrome://browser/content/browser-siteProtections.js:2511:20
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - handleProtectionsButtonEvent@chrome://browser/content/browser-siteProtections.js:1800:10
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - onclick@chrome://browser/content/browser.xhtml:1:21
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - synthesizeMouseAtPoint@chrome://mochikit/content/tests/SimpleTest/EventUtils.js:758:13
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - synthesizeMouse@chrome://mochikit/content/tests/SimpleTest/EventUtils.js:565:10
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - synthesizeMouseAtCenter@chrome://mochikit/content/tests/SimpleTest/EventUtils.js:846:10
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - openProtectionsPanel@chrome://mochitests/content/browser/browser/base/content/test/protectionsUI/head.js:57:16
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - testToggleSwitch@chrome://mochitests/content/browser/browser/base/content/test/protectionsUI/browser_protectionsUI.js:56:9
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - async*handleTask@chrome://mochikit/content/browser-test.js:1138:26
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - _runTaskBasedTest@chrome://mochikit/content/browser-test.js:1210:18
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - async*Tester_execTest@chrome://mochikit/content/browser-test.js:1352:14
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - nextTest/<@chrome://mochikit/content/browser-test.js:1127:14
[task 2023-12-11T09:02:07.683Z] 09:02:07     INFO - SimpleTest.waitForFocus/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:1058:13
Keywords: leave-open
Pushed by csabou@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a67f4665e2f3 Disable browser_protectionsUI.js on mac opt for frequent failures until a fix is in place. r=#intermittent-reviewers,jmaher
Whiteboard: [stockwell disable-recommended] → [stockwell disabled]
Assignee: nobody → pbz
Status: NEW → ASSIGNED
Flags: needinfo?(pbz)
Attachment #9371727 - Attachment description: Bug 1775855 - Wait for l10n to finish before inspecting label in test browser_protectionUI.js. r=#anti-tracking → Bug 1775855 - Wait for tooltip shown before in browser_protectionUI.js to fix race condition. r=#anti-tracking
Pushed by pzuhlcke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6892d832ec28 Re-enable browser_protectionsUI.js on macOS and Linux. r=anti-tracking-reviewers,bvandersloot https://hg.mozilla.org/integration/autoland/rev/d000edb9f771 Update browser_protectionsUI.js to reduce intermittent failures. r=bvandersloot https://hg.mozilla.org/integration/autoland/rev/a19aa74a7573 Wait for tooltip shown before in browser_protectionUI.js to fix race condition. r=bvandersloot

Looks like this needs more work. Still failing on macOS.

Attachment #9383875 - Attachment is obsolete: true
Assignee: pbz → nobody
Status: ASSIGNED → NEW

FWIW, I captured this pernosco trace while working on bug 1903758. My assumption would be that my changes most likely changed some timing (reducing sync overhead during free) which might make a race more likely to happen?

Flags: needinfo?(pbz)

Looks like the latest uptick is coming from Bug 1914793 which is triggered by a test added in Bug 1912405.

Flags: needinfo?(pbz)
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → INCOMPLETE
Status: RESOLVED → REOPENED
Resolution: INCOMPLETE → ---

Claude re-investigated this today. The diagnosis this bug has been carrying since 2023 no longer describes what is failing, which is likely part of why it has sat unowned for two years. Current data and a concrete root cause below.

THE EXISTING DIAGNOSIS IS STALE

Comment 81 pinned this on "TypeError: can't access property GetAvailRect, screen is null" inside PanelMultiView._calculateMaxHeight. That function no longer exists: it was removed in bug 1871515 ("Let nsMenuPopupFrame constrain the panelview, and remove _calculateMaxHeight"). Anyone opening this bug today is reading a stack trace for code that is not in the tree.

The patches in comment 95 (Jan 2024) fixed adjacent races - the tooltip wait and an l10n wait - and comment 100 correctly noted it needed more work. The bug was unassigned in April 2024 and has had nothing but weekly failure-count updates since. It was auto-closed INCOMPLETE in April 2025 and auto-reopened four days later, so even the cleanup automation just cycles it.

WHAT IS ACTUALLY FAILING NOW

Treeherder, trunk, last 6 months: 71 instances.

Platform:

  • macosx1015-64-qr debug: 68
  • windows11-32-25h2 opt: 1
  • macosx1500-aarch64 debug: 1
  • windows11-64-25h2 asan: 1

Note this is macOS debug. The Dec 2023 stockwell disable in comment 84 was mac opt, and it was re-enabled in Jan 2024. Different platform and different subtests from what the bug describes.

Failure signatures (only two subtests are involved):

  • 51 testMiniPanel - The panel header is displayed as the content of the toast.
  • 29 testMiniPanel - Test timed out
  • 28 testMiniPanelClick - The panel header is displayed as the content of the toast.
  • 28 testMiniPanelClick - Test timed out
  • 1 testNumberOfBlockedTrackers (noise)

The assertion failure and the timeout occur together in the same runs. That pairing is the tell - they are two symptoms of one race, described below.

Failures are spread across many workers (macmini-r8-94, -107, -213, -150, -225, -97, -155, -209, ...), so this is not one bad machine.

ROOT CAUSE

browser_protectionsUI.js:27 sets the toast auto hide to 100ms:

// Set the auto hide timing to 100ms for blocking the test less.
["browser.protections_panel.toast.timeout", 100],

browser-siteProtections.js:2652 arms that auto hide from a once-only popupshown listener registered before the popup is opened:

if (toast) {
  this._protectionsPopup.addEventListener(
    "popupshown",
    () => {
      this._toastPanelTimer = setTimeout(() => {
        PanelMultiView.hidePopup(this._protectionsPopup, true);
        delete this._toastPanelTimer;
      }, this._protectionsPopupToastTimeout);
    },
    { once: true }
  );
}

head.js:44 openProtectionsPanel() resolves on popupshown, i.e. after the timer is already armed.

And browser_protectionsUI.js:262 does its work after that await:

await openProtectionsPanel(true);        // resolves on popupshown; 100ms timer armed
let popuphiddenPromise = BrowserTestUtils.waitForEvent(popup, "popuphidden");
checkMiniPanel();                        // must finish within 100ms of popupshown
await popuphiddenPromise;

So checkMiniPanel() has a hard 100ms budget measured from the popupshown dispatch. On a loaded macOS debug worker that budget is regularly blown: the panel is already hiding, BrowserTestUtils.isVisible(header) returns false, and the ok() at browser_protectionsUI.js:251 fails with "The panel header is displayed as the content of the toast."

The timeout is the same race one step later. popuphiddenPromise is registered after the await, so when the hide has already happened the event is missed, the promise never resolves, and the task hangs until "Test timed out". That is why the two signatures always appear together.

testMiniPanelClick (browser_protectionsUI.js:289) has the same structure plus a second exposure: it must land a synthesized click on protections-popup-toast-panel-tp-on-desc before the 100ms auto hide fires. If the toast wins, the element is gone, the click does nothing, and both the popuphidden and popupshown promises hang.

THIS IS OLDER THAN THIS BUG

Bug 1628123 is "Intermittent browser_protectionsUI.js | The panel header is displayed as the content of the toast" - the identical assertion, filed in 2020, closed INCOMPLETE without a fix. The same race has been surfacing under at least two bug numbers for six years.

The recent doubling is explained too: testMiniPanelClick was added in bug 1912405 and copy-pasted the same pattern, duplicating the race into a second task. That is exactly what emz flagged in comment 143 in Sept 2024, and the current numbers confirm it - the two subtests now fail at roughly equal rates.

PROPOSED FIX

Three changes to browser_protectionsUI.js, no product code changes:

  1. Add a checkMiniPanelOnShown() helper that runs checkMiniPanel() synchronously from the popupshown dispatch itself. A setTimeout callback cannot interleave with synchronous code in the event dispatch, so the 100ms budget stops mattering entirely.

  2. Register the popuphidden listener before the panel is opened in both testMiniPanel and testMiniPanelClick, so the event cannot be missed. This removes the "Test timed out" half.

  3. In testMiniPanelClick, push browser.protections_panel.toast.timeout to 60000 for the duration of that task. The auto hide is not what that task tests, and the synthesized click must not have to race it. testMiniPanel keeps the short timeout because it genuinely does test auto hide, and still asserts "The mini panel hides automatically."

VERIFICATION STATUS - PLEASE READ

Local runs on macOS pass cleanly with the patch (70 passed / 0 failed), and both mini panel subtests passed every iteration of mach mochitest --verify that completed.

However, local testing cannot demonstrate this fix works. The failure is macOS debug under CI load and it does not reproduce locally - an unpatched baseline passed 26/26 mini panel iterations here. Local runs only show nothing was broken.

Worth noting for anyone running --verify on this file: it is flaky in unrelated places in both the patched and unpatched states. A patched run aborted on testSubViewTelemetry and an unpatched baseline aborted on testQuickSwitchTabAfterTogglingTPSwitch. Neither subtest is touched by this patch, and neither has its own bug on file. --verify is not a reliable signal for this file.

Real validation needs a try push on macOS debug browser-chrome with --rebuild, e.g.:

./mach try fuzzy -q "'mochitest-browser-chrome 'macosx 'debug" --rebuild 20

ALSO WORTH CLEANING UP

The whiteboard still said [stockwell disabled] from the Dec 2023 mac opt disable, but the test was re-enabled in Jan 2024 (comment 95) and currently has no skip-if in browser/base/content/test/protectionsUI/browser.toml. That tag was misleading, so I am clearing it as part of this update.

Whiteboard: [stockwell disabled]
Status: REOPENED → RESOLVED
Closed: 1 year ago → 1 month ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: