fix: destroy PixiJS app on prenav to avoid WebGL context loss

Cleanup now runs on the prenav event (before SPA navigation starts)
while the WebGL context is still valid, eliminating the TexturePool
errors during app.destroy(). The try/catch remains as a silent
safety net for edge cases.
This commit is contained in:
saberzero1 2026-04-04 20:24:29 +02:00
parent 05bf33de90
commit c54226d895
No known key found for this signature in database
5 changed files with 10 additions and 8 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -592,10 +592,8 @@ import {
simulation.stop();
try {
app.destroy(true);
} catch (e) {
// PixiJS may throw if WebGL context was already lost (e.g. during SPA navigation).
// Swallow the error so cleanup completes and the graph can re-render.
console.warn("[Graph] PixiJS destroy failed (WebGL context likely lost):", e);
} catch (_) {
// PixiJS may throw if WebGL context was already lost.
}
};
}
@ -766,6 +764,10 @@ import {
} else {
handleNav({ detail: { url: getSlugFromUrl() } });
}
document.addEventListener("prenav", function () {
cleanupLocal();
cleanupGlobal();
});
document.addEventListener("nav", handleNav);
document.addEventListener("render", handleNav);
}