Open Bug 2002658 Opened 1 year ago Updated 4 days ago

High frequency dom/media/autoplay/test/mochitest/test_autoplay_policy_key_blacklist.html | single tracking bug

Categories

(Core :: Audio/Video: Playback, defect, P5)

defect

Tracking

()

People

(Reporter: intermittent-bug-filer, Unassigned, NeedInfo)

References

(Blocks 1 open bug)

Details

(Keywords: intermittent-failure, intermittent-testcase, Whiteboard: [collect_confirm_failure])

Filed by: csabou [at] mozilla.com
Parsed log: https://treeherder.mozilla.org/logviewer?job_id=537565151&repo=mozilla-central&task=cj1KI_iHSouKHFRPWs7MFA.0
Full log: https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/cj1KI_iHSouKHFRPWs7MFA/runs/0/artifacts/public/logs/live_backing.log


[task 2025-11-26T22:17:06.187+00:00] 22:17:06     INFO - TEST-PASS | dom/media/autoplay/test/mochitest/test_autoplay_policy_key_blacklist.html | Document should start out not activated, with playback blocked. 
[task 2025-11-26T22:17:06.188+00:00] 22:17:06     INFO - Buffered messages finished
[task 2025-11-26T22:17:06.188+00:00] 22:17:06     INFO - TEST-UNEXPECTED-FAIL | dom/media/autoplay/test/mochitest/test_autoplay_policy_key_blacklist.html | Test timed out. - 
[task 2025-11-26T22:17:06.997+00:00] 22:17:06     INFO - GECKO(1525) | MEMORY STAT | vsize 2638MB | residentFast 135MB | heapAllocated 10MB
[task 2025-11-26T22:17:07.002+00:00] 22:17:07     INFO - Error: Unable to restore focus, expect failures and timeouts.
[task 2025-11-26T22:17:07.012+00:00] 22:17:07     INFO - TEST-OK | dom/media/autoplay/test/mochitest/test_autoplay_policy_key_blacklist.html | took 324635ms
[task 2025-11-26T22:17:07.027+00:00] 22:17:07     INFO - TEST-START | dom/media/autoplay/test/mochitest/test_autoplay_policy_permission.html
Duplicate of this bug: 2002564

If this is tree related it has started somewhere before this.

See Also: → 2012615

Hi, could you please take a look and assign someone to fix this issue? It has 170 failures in the last month.

Flags: needinfo?(jmathies)
Summary: Intermittent dom/media/autoplay/test/mochitest/test_autoplay_policy_key_blacklist.html | single tracking bug → High frequency dom/media/autoplay/test/mochitest/test_autoplay_policy_key_blacklist.html | single tracking bug

This intermittent timeout occurs only on Windows 11 25h2, on opt and shippable builds, 32 and 64 bit. Treeherder shows 43 failures from 2026-10-25 to 2026-11-01.

Analysis

The CI logs of tasks fTI_ZFdaQWaw-S-6rCPlaA and VPagsbOASCKUwLdGmOKNog show two hang points. In both, a synthesized key never reaches the popup document, and the test waits until the harness timeout. The retry in a new browser also fails, so earlier tests do not cause it. The logs show no JS error and no assertion.

  • Pattern A: the hang is at the first key, CapsLock, in the first popup. The log has no "Received keydown event: CapsLock" line.
  • Pattern B: all blocklisted keys and Space pass in the first popup. The hang is at Ctrl+F5 in the second popup, in testCtrlF5Activation. The log has no "Received keydown event: F5" line.

The probable cause is a focus race in the test. The opener waits only for the popup load event, then posts the message (test_autoplay_policy_key_blacklist.html). It does not wait for the popup to get focus. The helper sends each key one time from a chrome script into Services.wm.getMostRecentWindow("navigator:browser") (file_autoplay_policy_key_blacklist.html). The key goes to the focused element of that chrome window. If the content <browser> does not have focus yet, chrome gets the key and the one-shot keydown listener never fires.

The line "Unable to restore focus" after each timeout agrees with this. The popup stays open because child.close() never runs. No log proves where the key lands yet. A try run with MOZ_LOG=Focus:5, or an info() that logs the focused element of browserWin when the key is sent, can confirm it. Why only the Windows 11 workers show the race is not known. Bug 2012615 also shows focus failures on these workers.

Regression status: no change in Firefox code is known to cause this. No change to the test or the helper matches the start of the failures in November 2025. Bug 2001938 added the second popup and the Ctrl+F5 subtest, where Pattern B hangs.

Fix direction

The fix stays in the two test files under dom/media/autoplay/test/mochitest/:

  1. In the opener, await SimpleTest.promiseFocus(child) after the load event.
  2. Send each key to the popup window, not to getMostRecentWindow.
  3. Focus the content <browser> of that window before each key.
  4. Close the popup in a SimpleTest.registerCleanupFunction, so a failure does not affect later tests.

This bug blocks the autoplay meta bug 2023365. It also waits for the request to Jim Mathies in comment 102. Alastor, could you please look at this fix direction, because the test covers the autoplay policy?


If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.

Blocks: autoplay
Flags: needinfo?(alwu)
See Also: → 2001938
You need to log in before you can comment on or make changes to this bug.