Our Babylon React Native Android app’s performance slowly degrades over time until the app crashes. Initial investigations suggest a memory leak from Engine._renderLoop() as the performance degradation occurs despite no new geometry or shaders being added to the scene. The user can simply be occasionally rotating, panning and zooming the ArcRotateCamera around the scene and the frame rate falls.
Unsure if it’s an issue with our code or that of Babylon.js or Babylon Native. I’ve yet to replicate this in a simpler app.
Does anyone on the Babylon Native team have any advice on how we can better investigate this to narrow down the issue?
I guess you need a profiler. If you are using React Native with JSC, I don’t believe it is possible to profile JSC on Android, but it should be possible on iOS. If you are targeting Hermes, then it should be possible on Android or iOS but I’ve never tried it myself. Otherwise, adding code to time the render loop and slowly change the code to drill into the slow parts is likely your best bet. Does the same slowness happen with the Playground app for Babylon React Native?
Do you repro with BabylonNative alone? if it happens in Engine._renderLoop() then it should also be visible in BN alone. It makes debugging easier. Moreover, with ChromeDevTools and V8, you should be able to do memory snapshots.
What I’m seeing at the moment is the issue seems to be isolated to V8 JIT (version 10.100.1). When I switch to either JavaScriptCore or Hermes I see no evidence of a memory leak, plus the debugging and profiling options for Hermes are a lot better. V8 JIT is better for intensive data processing though, which is one of our requirements. I’ll try updating the V8 version …