Chromium tab crashes when calling chrome.debugger.detach after Emulation.setEmulatedMedia
ruifigueira opened this issue · 1 comments
ruifigueira commented
In recent chromium versions, when detaching playwright-crx, the corresponding tab crashes with Error code: STATUS_BREAKPOINT
:
I was able to track down the issue to Emulation.setEmulatedMedia
when setting forced-colors
feature to either none
or active
. Even though the instruction executes successfully, it crashes the attached tab when we try to detach it using chrome.debugger.detach
.
Minimal code for a chrome extension that reproduces the bug on Chromium 119.0.6045.9, Windows 11:
- manifest.json:
{
"name": "Bug crash - forced-colors",
"version": "0.0.1",
"manifest_version": 3,
"background": {
"service_worker": "background.js",
"type": "module"
},
"permissions": ["debugger", "tabs"]
}
- background.js:
(async () => {
const { id: tabId } = await chrome.tabs.create({ url: 'about:blank' });
await chrome.debugger.attach({ tabId }, '1.3');
await chrome.debugger.sendCommand({ tabId }, 'Emulation.setEmulatedMedia', { media: "", features: [{name: "forced-colors", value: "none" }]});
// detaching will crash the tab with
await chrome.debugger.detach({ tabId });
})();
In Chromium 117.0.5938.62, the issue doesn't occurr.
ruifigueira commented
Issue reported in chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=1499656