Offscreen document and user profiles

94 views
Skip to first unread message

Timur Allamiyarov

unread,
Jun 18, 2024, 5:28:49 AM (11 days ago) Jun 18
to Chromium Extensions
Hello fellow devs!

I am currently developing an MV3 extension that utilises an Offscreen Document. It seems that when I log in as user A (who has the MV3 extension installed) and close their browser window, then log in as user B, the latter will experience a loss of internet connection. 

Interestingly, this problem does not occur if the Offscreen Document is closed before closing the browser window. I am using version 126.0.6478.61 of the Chrome browser.

Has anyone else encountered this issue? Is there a foolproof method to programmatically close an Offscreen Document when a browser window is closed?

woxxom

unread,
Jun 18, 2024, 8:43:17 AM (11 days ago) Jun 18
to Chromium Extensions, Timur Allamiyarov
There's a bug in Chrome (extension processes aren't terminated when profile's last window is closed), https://crbug.com/41226999, but it should be fixed since Chrome 100 by default and I can't reproduce it here in Chrome 125 and 128.
  • Maybe you have some windows still open like devtools
  • Maybe your manifest.json has "permissions":["background"]
  • Maybe DestroyProfileOnBrowserClose is disabled in chrome://version/?show-variations-cmd
Either way you can probably use chrome.windows.onRemoved to detect this situation and close the document accordingly.

woxxom

unread,
Jun 18, 2024, 8:45:52 AM (11 days ago) Jun 18
to Chromium Extensions, woxxom, Timur Allamiyarov
If I'm not mistaken, DestroyProfileOnBrowserClose may be still disabled for some users via Chrome's field trials, so try exiting all Chrome processes and start it with --enable-features=DestroyProfileOnBrowserClose command line.
Reply all
Reply to author
Forward
0 new messages