mirror of
https://github.com/nimbold/Firelink.git
synced 2026-09-01 21:48:00 +00:00
fix(startup): defer renderer IPC past load callback (#37)
- Issue #37: Windows still overflowed when startup IPC ran from the WebView2 load callback. - Release the renderer startup gate on the next event-loop task after load returns. - Keep logger and console forwarding behind the same post-load boundary. Fixes #37.
This commit is contained in:
+9
-2
@@ -22,11 +22,18 @@ const isPropertiesWindow = getCurrentWindow().label.startsWith('properties-');
|
||||
// also needed for Zustand persistence, whose module initialization reads the
|
||||
// native database before React mounts.
|
||||
const documentLoaded = new Promise<void>((resolve) => {
|
||||
const releaseAfterNativeLoad = () => {
|
||||
// The load event is dispatched from WebView2's navigation callback. Move
|
||||
// renderer startup to the next task so its first IPC cannot re-enter that
|
||||
// native callback stack.
|
||||
window.setTimeout(resolve, 0);
|
||||
};
|
||||
|
||||
if (document.readyState === 'complete') {
|
||||
resolve();
|
||||
releaseAfterNativeLoad();
|
||||
return;
|
||||
}
|
||||
window.addEventListener('load', () => resolve(), { once: true });
|
||||
window.addEventListener('load', releaseAfterNativeLoad, { once: true });
|
||||
});
|
||||
|
||||
void documentLoaded.then(() => {
|
||||
|
||||
Reference in New Issue
Block a user