Environment
- react-native-fast-tflite: 2.0.0
- React Native: 0.84 (bridgeless mode)
- iOS
Problem
TensorflowPlugin.cpp captures runtime by reference ([=, &runtime])
in async lambdas passed to callInvoker->invokeAsync. When the lambda
executes asynchronously, the runtime reference is dangling — causing
EXC_BAD_ACCESS.
Two occurrences:
callInvoker->invokeAsync([=, &runtime]() { ← loadTensorflowModel
this->_callInvoker->invokeAsync([=, &runtime]() { ← run()
Fix
Capture runtime by pointer instead:
// BEFORE
callInvoker->invokeAsync([=, &runtime]() {
auto result = jsi::Object::createFromHostObject(runtime, plugin);
promise->resolve(std::move(result));
});
// AFTER
auto* runtimePtr = &runtime;
callInvoker->invokeAsync([=]() {
auto result = jsi::Object::createFromHostObject(*runtimePtr, plugin);
promise->resolve(std::move(result));
});
Same fix for the second occurrence in run().
Workaround
Use react-native-nitro-tflite (unofficial drop-in replacement).
Environment
Problem
TensorflowPlugin.cppcapturesruntimeby reference ([=, &runtime])in async lambdas passed to
callInvoker->invokeAsync. When the lambdaexecutes asynchronously, the
runtimereference is dangling — causingEXC_BAD_ACCESS.
Two occurrences:
callInvoker->invokeAsync([=, &runtime]() {← loadTensorflowModelthis->_callInvoker->invokeAsync([=, &runtime]() {← run()Fix
Capture runtime by pointer instead:
Same fix for the second occurrence in
run().Workaround
Use
react-native-nitro-tflite(unofficial drop-in replacement).