{{ message }}
Repository navigation
Conversation
…and start a new scene" The Jolt world of a paused scene is now freed and rebuilt when the scene is resumed, with the velocities of the bodies.
Contributor
⏱️ Game engine benchmarks: ✅ no significant change on the 31 benchmarksAll the 31 benchmarks and how they are measured✅ The counters (draw calls, objects count and final state) of the 9 scene benchmarks run on both versions are unchanged. Comparing |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #8640
Problem
The Jolt WASM module used by Physics3D has a fixed 128 MB heap (no memory growth:
emscripten_resize_heapaborts withOOM). EachJoltInterfacecreated with the default settings takes about 20 MB, so only 6 physics worlds fit.A scene paused with "Pause and start a new scene" kept its Jolt world alive, as it was only freed when the scene was unloaded. Stacking scenes with Physics3D objects crashed the game with
RuntimeError: Aborted(OOM)innew JoltInterfaceat the 6th stacked scene.Fix
In
Physics3DSharedData:releaseJoltWorld()stores the linear and angular velocities of every body, destroys the bodies and frees the Jolt world.restoreJoltWorld()recreates the Jolt world and the bodies with their velocities.What is lost across a pause: contacts in progress (collision "started" conditions trigger again after the resume), the sleeping state of bodies, and the internal state of characters (like being on the floor).
Performance before/after
Measured on the reproduction project of the issue (scene "Bug": 200 dynamic boxes, the scene pushes a new copy of itself every 0.5 s).
Aborted(OOM)at the 6th)The cost of the fix is only paid when a scene is paused or resumed: a few milliseconds for 200 bodies. Frame time is unchanged.
How to test
Repro8640-Physics3DPushSceneOOM.zip
Videos
Crash on Master
https://github.com/user-attachments/assets/fbeaaaf6-a5a8-43f6-a184-2cfa1cf9d237
This PR
https://github.com/user-attachments/assets/b0251318-29cf-4f9b-930b-510ab05333bf