jhugman / uniffi-bindgen-react-native

A uniffi bindings generator for calling Rust from react-native
https://jhugman.github.io/uniffi-bindgen-react-native/
Other
50 stars 5 forks source link

Fixup callbacks deadlock when calling callback very frequently #158

Closed jhugman closed 1 week ago

jhugman commented 1 week ago

Fixes #157

Minimal test: 146cd396aed959e69bf78d898986656d67675d92

The change here is in UniffiCallInvoker, reverting the implementation of invokeBlocking back to the Promise based implementation introduced in PR https://github.com/jhugman/uniffi-bindgen-react-native/pull/88.

The deadlock rate for the test is now 0/50.

/cc @tayrevor

Adding any more to the implementation (e.g. uncommenting the console.log) causes the same error as before, but it is completely deterministic:

-- Going to 1024, now at: 264
-- Going to 1024, now at: 265
Assertion failed: (usedDbg_ && "Stats not submitted."), function ~CollectionStats, file HadesGC.cpp, line 259.

On my machine it always stops after 265/1024. I am still unsure if this is a problem with production uniff-bindgen-react-native code, an artifact of the test-harness or something weirder.

I'm going to suggest that this is addressed in a separate issue.

trevoranderson commented 1 week ago

This seems like the issue I had. I experienced this both in release builds (XCode archive and run on devices from TestFlight) and locally with a debug build run directly on my iPhone 10s test device.

For reference, this is the stack trace of the hung thread for me. image