Unable to read files from asar after 10+ hours of runtime

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    11.2.3, 11.2.3, 11.3.0
  • Operating System:
    Windows 10
  • Last Known Working Electron version:
    8.5.5

Expected Behavior

Electron should correctly load resource from asar with file protocol.

Actual Behavior

After some runtime any file you try to load from asar fails to load with net::ERR_FILE_NOT_FOUND

To Reproduce

Run the Electron for 10+ hours and from time to time try to read file from asar. After some time will start getting errors net::ERR_FILE_NOT_FOUND on all files.

Screenshots

Additional Information

1 possible answer(s) on “Unable to read files from asar after 10+ hours of runtime

  1. @MarshallOfSound @ckerr I have been debugging the code on Window with 32bit Electron and here is what I found:

    The problem happens in https://github.com/electron/electron/blob/11-x-y/shell/common/asar/archive.cc where in the constructor Archive::Archive the method file_.Initialize returns false. The reason why it returns false is that in file https://github.com/chromium/chromium/blob/87.0.4264.1/base/files/memory_mapped_file_win.cc inside method MemoryMappedFile::MapFileRegionToMemory a Windows function ::MapViewOfFile is called and it returns NULL.

    This feature was introduced in Electron 11 with #24470 @nornagon

    My best guess is that it is failing because it runs out of memory/handlers given that I see several dozen opened file handles to the asar archive in Process Explorer. In the asar_util.cc there is a global map g_archive_map_tls which creates a new instance of Archive for every thread, which seems to be happening quite often from what I have seen in debugger. Since content of that map is never released, at some point Windows probably just refuses to allocate more resources.

    You can test this problem with Skype insiders on Windows https://www.skype.com/en/insider/ . You just need to log in, let it run for about 10hours, and then you can observe in settings menu that icons are missing which is a sign that Skype is not able to load them from asar. Unfortunately Skype is using private build of Electron so public symbols will not work, but I can send you correct one of you are Microsoft employee.