BabylonNative icon indicating copy to clipboard operation
BabylonNative copied to clipboard

Main thread is blocked when rendering for Playground app on macOS and iOS

Open bghgary opened this issue 4 years ago • 2 comments

The playground app on macOS and iOS:

https://github.com/BabylonJS/BabylonNative/blob/a02f821a2cae1c935377f7074e456dbb63de8dee/Apps/Playground/iOS/LibNativeBridge.mm#L105-L112

https://github.com/BabylonJS/BabylonNative/blob/76e5ba1ee58fb4ed10ae72de0a3253e434f09686/Apps/Playground/macOS/ViewController.mm#L39-L44

The code is currently calling FinishRenderingCurrentFrame immediately following StartRenderingCurrentFrame. FinishedRenderingCurrentFrame will immediately block waiting for the JS thread to finish doing its part. Ideally, these calls should be backwards. StartRenderingCurrentFrame should be called as soon as possible and FinishRenderingCurrentFrame should be called as late as possible. There should be a small gap between FinishRenderingCurrentFrame and the next StartRenderingCurrentFrame.

Oddly, the validation tests for macOS and iOS does it correctly:

https://github.com/BabylonJS/BabylonNative/blob/a02f821a2cae1c935377f7074e456dbb63de8dee/Apps/ValidationTests/iOS/LibNativeBridge.mm#L87-L93

https://github.com/BabylonJS/BabylonNative/blob/a02f821a2cae1c935377f7074e456dbb63de8dee/Apps/ValidationTests/macOS/ViewController.mm#L36-L41

bghgary avatar Feb 17 '22 01:02 bghgary

Related: https://github.com/BabylonJS/BabylonReactNative/issues/343

bghgary avatar Feb 17 '22 01:02 bghgary

This is a resize issue because RenderTarget and other resources are still being used while resize occurs. Issue doesn't appear with VT because there is no resize allowed there.

CedricGuillemet avatar Feb 18 '22 11:02 CedricGuillemet

fixed

thomlucc avatar Mar 26 '24 16:03 thomlucc