Open Bug 1768532 Opened 3 years ago Updated 3 years ago

NS_ERROR_FILE_ACCESS_DENIED on Windows when tab is closed before extension unload

Categories

(WebExtensions :: General, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: robwu, Unassigned)

References

Details

There have been intermittent test failures on Windows, where the test extension fails to shut down cleanly, because the generated XPI file cannot be removed, most likely because something is still accessing its file content. There have been two recent cases where the failure was resolved by unloading the extension before closing the content pages. While this work-around may address the intermittemt test failures, it would be ideal if we identify and resolve the root cause that is responsible for them.

bug 1761550 - mochitest/test_ext_scripting_contentScripts.html

Relevant actions that resulted in an intermittent failure on Windows ("winLastError":5 aka ERROR_ACCESS_DENIED):

  1. Loads two extensions with dynamic session-scoped content scripts (scripting.registerContentScripts).
  2. Open https:-URL where one content script executes and returns control to the test runner.
  3. Close tab.
  4. Unloads both extensions.

Swapping the last two steps resolved the intermittent failure: https://bugzilla.mozilla.org/show_bug.cgi?id=1761550#c13

bug 1768059 - xpcshell/test_ext_contentscript_importmap.js

Relevant actions that resulted in an intermittent failure on Windows (NS_ERROR_FILE_ACCESS_DENIED):

  1. Loads extension with content script in manifest.json.
  2. Loads http:-page where the content script executes and returns control to test runner.
  3. Loads moz-extension:-page where the content script executes and returns control to test runner.
  4. Closed both pages (from step 2 and 3).
  5. Unloads extension.

Swapping the last two steps resolved the intermittent failure: https://bugzilla.mozilla.org/show_bug.cgi?id=1768059#c4

About the second test (bug 1768059 - xpcshell/test_ext_contentscript_importmap.js), we can be more specific.

We don't have to fully move the "Close both pages (from step 2 and 3)" step after "Unload extension".
Just moving the "Close http:-page from step 2" after unloading the extension fixed the failures. It doesn't matter whether the extension page was closed before or after unloading the extension. Both scenarios (closing extension page before or after unloading) have been tested in https://phabricator.services.mozilla.com/D145912?id=577045#inline-804743

With this additional information, the common factor to both intermittents is that the closing of the content page has been postponed to after the unload of the extension has been completed.

This suggests that the closing of a web page (or shut down of a content process?) may potentially keep a handle to the XPI file open that interferes with the attempt to remove the XPI file at extension shutdown.

Severity: -- → S3
Priority: -- → P3
See Also: → 1782359
You need to log in before you can comment on or make changes to this bug.