Skip to content

Commit c9417e3

Browse files
authored
Fix blank popup window bug on Firefox (#1610)
Resolves #1609 There's a bug that affects (at least) Firefox on Win10 where if the user tries View > Dedicated Window, the window comes up blank and the JS console has errors about "can't access dead object". The issue seems like a bug in Firefox. What seems to be happening is that the popup is trying to share resources with the main window, but the browser's garbage seems to not be aware of the additional reference. So the popup starts loading, we redirect the original window, which causes the browser to tear down its resources, and then the popup continues loading, but the shared resources it was trying to access have been garbage collected in redirecting the original window. Adding `noopener` seems to fix the issue, as it prevents the two windows from sharing resources: >`noopener` > >If this feature is set, the new window will not have access to the originating window via Window.opener and returns null. > >When `noopener` is used, non-empty target names, other than _top, _self, and _parent, are treated like _blank in terms of deciding whether to open a new browsing context. https://developer.mozilla.org/en-US/docs/Web/API/Window/open#parameters
1 parent 7014293 commit c9417e3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/static/js/app.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,11 @@ menuBar.addEventListener("dedicated-window-requested", () => {
342342
window.open(
343343
"/?viewMode=standalone",
344344
undefined,
345-
`popup=true,width=${width},height=${height}`
345+
// We need to add noopener to prevent a bug on Firefox where tearing down
346+
// the existing page causes the browser to garbage collect resources that
347+
// the popup tries to access.
348+
// https://github.com/tiny-pilot/tinypilot/issues/1609
349+
`popup=true,noopener,width=${width},height=${height}`
346350
);
347351

348352
// Redirect the user to a placeholder page. We can’t keep the main window

0 commit comments

Comments
 (0)