Prevent automatic suspension of event page when downloads.download() is awaiting user input via file chooser
Categories
(WebExtensions :: General, defect, P3)
Tracking
(firefox149 fixed)
| Tracking | Status | |
|---|---|---|
| firefox149 | --- | fixed |
People
(Reporter: robwu, Assigned: robwu)
References
(Blocks 2 open bugs)
Details
(Whiteboard: [addons-jira])
Attachments
(1 file)
See bug 2005952 for the motivation.
A work-around to limit the impact of bug 2005952 is to postpone event page termination while the downloads.download() call is blocked on user input (file saver dialog). I created a patch and it seems to work.
| Assignee | ||
Comment 1•1 month ago
|
||
| Assignee | ||
Updated•1 month ago
|
Updated•1 month ago
|
Comment 4•20 days ago
|
||
Reverted this because it was causing xpcshell assertion failures.
- Revert link
- Push with failures
- Failure Log
- Failure line: Assertion failure: mDestructCalled, at /builds/worker/checkouts/gecko/dom/base/nsDOMWindowUtils.cpp:X
| Assignee | ||
Comment 5•20 days ago
|
||
The test did indeed fail on Windows, but not for the reason highlighted in comment 4. That assertion error is from a different test and tracked in bug 1993378.
The relevant failure log in the context of this bug is as follows. The logs show that the test is stuck waiting for the file to finish writing the content, waiting at https://hg-edge.mozilla.org/integration/autoland/rev/d5c4850ed1c2#l3.119 . This could be general slowness on the Windows test machine, or be a quirk from the way that downloads are processed on Windows. By default, waitForCondition waits for 5 seconds, which ought to be enough...
[task 2026-01-13T22:17:36.934+00:00] 22:17:36 INFO - "Calling downloads.download with URL blob:moz-extension://78efe15a-8bd0-4834-ab8e-9a57039f7b1b/7516fb1c-4aef-439e-bb8e-562576b6590c"
[task 2026-01-13T22:17:36.936+00:00] 22:17:36 INFO - "Waiting for file picker to have been shown."
[task 2026-01-13T22:17:36.936+00:00] 22:17:36 INFO - TEST-PASS | xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_downloads_blob_url.js | test_download_blob_with_slow_file_picker - [test_download_blob_with_slow_file_picker : 69] File picker should show once - 1 == 1
[task 2026-01-13T22:17:36.936+00:00] 22:17:36 INFO - "Delaying file picker completion past background idle timeout"
[task 2026-01-13T22:17:37.046+00:00] 22:17:37 INFO - "Returning from file picker after background idle timeout passed"
[task 2026-01-13T22:17:37.047+00:00] 22:17:37 INFO - TEST-PASS | xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_downloads_blob_url.js | test_download_blob_with_slow_file_picker - [test_download_blob_with_slow_file_picker : 106] File picker was shown once - 1 == 1
[task 2026-01-13T22:17:37.051+00:00] 22:17:37 INFO - "Waiting until blob was saved to chosen file at C:\Users\task_176834088148911\AppData\Local\Temp\xpc-profile-ejlz0fa2\dldir\result.txt"
[task 2026-01-13T22:17:37.052+00:00] 22:17:37 INFO - "Waiting until file was fully written"
[task 2026-01-13T22:17:37.052+00:00] 22:17:37 INFO - "Clearing pref "extensions.background.idle.timeout""
[task 2026-01-13T22:17:37.052+00:00] 22:17:37 INFO - TEST-ERROR | xpcshell-remote.toml:toolkit/components/extensions/test/xpcshell/test_ext_downloads_blob_url.js | Unexpected exception undefined - timed out after 50 tries.
| Assignee | ||
Comment 6•20 days ago
|
||
After inspecting relevant I/O code, I think that I figured out the issue.
On Windows, nsIFile.size (impl)'s return value is constant after the first access because the stat result is cached. A potential work-around could be to call file.exists(), because that marks the file instance as dirty to force a new stat.
On macOS (where I tested the patch), nsIFile.size returns the latest state of the file. It used to also have a stat cache, but that was removed 17 years ago in bug 456435.
Backed out for causing xpcshell failures
| Assignee | ||
Comment 10•19 days ago
|
||
Ah... I see what is going on.
Despite automation closing bug 2005963, the patch to that bug has not actually landed, because it was backed out in comment 4 here. So, what I will be doing is to re-open bug 2005963, re-parent the patch to the patch from that other bug, and reland the whole stack.
I drew that conclusion, because obviously the revert from comment 4 includes the other bug, while the log of the failing land attempt contains this error:
JavaScript Error: "can't access property "window", global.windowTracker.getTopWindow() is null" {file: "chrome://extensions/content/parent/ext-downloads.js" line: 931}]
That line points to the current in-tree code at https://searchfox.org/firefox-main/rev/5917a9f2af3294b27a325371c5c499e7dd9554fd/toolkit/components/extensions/parent/ext-downloads.js#931
... which is something that the patch at bug 2005963 was meant to fix.
Comment 11•19 days ago
|
||
Comment 12•19 days ago
|
||
| bugherder | ||
Description
•