File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -139,9 +139,12 @@ napi_status ThreadSafeFunction::call(
139139 log_debug (" Error: No CallInvoker available for ThreadSafeFunction" );
140140 return napi_generic_failure;
141141 }
142- // Hop to JS thread; we drain one item per hop to keep latency predictable
143- // and avoid long monopolization of the JS queue.
144- invoker->invokeAsync ([self = shared_from_this ()] { self->processQueue (); });
142+ // Invoke from the current thread. Libraries like NativeScript can wrap a
143+ // JS function in an Objective-C block to be dispatched onto another thread
144+ // (e.g. the main thread, with the intention of accessing the UI), and so we
145+ // should run the JS function on the same thread the Objective-C block was
146+ // dispatched to.
147+ invoker->invokeSync ([self = shared_from_this ()] { self->processQueue (); });
145148 return napi_ok;
146149}
147150
You can’t perform that action at this time.
0 commit comments