Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(engine): post-processing survives a warm re-play (no black screen)

yhh1c7cf36d90c4
diff --git a/src/esengine/bindings/PostProcessBindings.cpp b/src/esengine/bindings/PostProcessBindings.cpp
index 38a0526f0..fff32df32 100644
--- a/src/esengine/bindings/PostProcessBindings.cpp
+++ b/src/esengine/bindings/PostProcessBindings.cpp
@@ -42,8 +42,16 @@ bool postprocess_init(u32 width, u32 height) {
void postprocess_shutdown() {
if (g_postProcessPipeline) {
+ // Tear down the passes/FBOs/blit shader, but KEEP the service registered.
+ // The pipeline is owned by RenderFrame (registered as a bare-pointer service
+ // and the very object RenderFrame::begin renders through). Unregistering it
+ // here orphaned it on a warm re-play: `postprocess_init` then saw no service,
+ // built a *separate* owned duplicate, and RenderFrame kept using its own —
+ // now permanently un-initialized — pipeline, so `usePostProcess` went false
+ // and a linear-space scene rendered without the mandatory linear→sRGB encode
+ // (i.e. black). Leaving it registered lets the lazy re-init (_applyForCamera →
+ // init → resize) restore the SAME pipeline RenderFrame draws with.
g_postProcessPipeline->shutdown();
- ctx().services().removeService<PostProcessPipeline>();
}
}