objc-js 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
package/package.json
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"format": "prettier --write \"**/*.{ts,js,json,md}\"",
|
|
40
40
|
"preinstall-disabled": "npm run build-scripts && npm run make-clangd-config"
|
|
41
41
|
},
|
|
42
|
-
"version": "0.0.
|
|
42
|
+
"version": "0.0.11",
|
|
43
43
|
"description": "Objective-C bridge for Node.js",
|
|
44
44
|
"main": "dist/index.js",
|
|
45
45
|
"dependencies": {
|
|
@@ -551,7 +551,15 @@ void ForwardInvocation(id self, SEL _cmd, NSInvocation *invocation) {
|
|
|
551
551
|
js_thread = it->second.js_thread;
|
|
552
552
|
|
|
553
553
|
// Get the ThreadSafeFunction - this is thread-safe by design
|
|
554
|
+
// IMPORTANT: We must Acquire() to increment the ref count, because copying
|
|
555
|
+
// a ThreadSafeFunction does NOT increment it. If DeallocImplementation runs
|
|
556
|
+
// and calls Release() on the original, our copy would become invalid.
|
|
554
557
|
tsfn = callbackIt->second;
|
|
558
|
+
napi_status acq_status = tsfn.Acquire();
|
|
559
|
+
if (acq_status != napi_ok) {
|
|
560
|
+
NSLog(@"Warning: Failed to acquire ThreadSafeFunction for selector %s", selectorName.c_str());
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
555
563
|
|
|
556
564
|
// Get the type encoding for return value handling
|
|
557
565
|
auto encIt = it->second.typeEncodings.find(selectorName);
|
|
@@ -571,6 +579,9 @@ void ForwardInvocation(id self, SEL _cmd, NSInvocation *invocation) {
|
|
|
571
579
|
|
|
572
580
|
if (is_js_thread) {
|
|
573
581
|
// We're on the JS thread, so it's safe to access N-API values directly
|
|
582
|
+
// Release the TSFN we acquired - we don't need it on this path
|
|
583
|
+
tsfn.Release();
|
|
584
|
+
|
|
574
585
|
// Do a second lookup to get the JS callback
|
|
575
586
|
// IMPORTANT: We must call .Value() while holding the lock to prevent
|
|
576
587
|
// DeallocImplementation from erasing the entry while we're using it
|
|
@@ -607,6 +618,10 @@ void ForwardInvocation(id self, SEL _cmd, NSInvocation *invocation) {
|
|
|
607
618
|
// Use ThreadSafeFunction to marshal to JS thread
|
|
608
619
|
napi_status status = tsfn.BlockingCall(data, CallJSCallback);
|
|
609
620
|
|
|
621
|
+
// Release our acquired reference to the TSFN
|
|
622
|
+
// This balances the Acquire() call above
|
|
623
|
+
tsfn.Release();
|
|
624
|
+
|
|
610
625
|
if (status != napi_ok) {
|
|
611
626
|
NSLog(@"Error: Failed to call ThreadSafeFunction for selector %s (status: %d)",
|
|
612
627
|
selectorName.c_str(), status);
|