Skip to content

Commit f28c1c1

Browse files
committed
Re-enable guarded JSValueUnprotect
1 parent 29d2c0b commit f28c1c1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/SkipScript/JSContext.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class JSContext {
2121
public let context: JSContextRef
2222
public private(set) var exception: JSValue? = nil
2323
private var tryingRecursionGuard = false
24+
var released = false
2425

2526
public init(jsGlobalContextRef context: JSContextRef) {
2627
self.context = context
@@ -33,6 +34,7 @@ public class JSContext {
3334

3435
deinit {
3536
JavaScriptCore.JSGlobalContextRelease(context)
37+
self.released = true
3638
}
3739

3840
@discardableResult fileprivate func clearException(_ exception: ExceptionPtr? = nil) -> Bool {
@@ -562,7 +564,9 @@ public class JSValue {
562564
02-06 14:33:12.997 2016 2016 F DEBUG : #11 pc 0000000000185e6b /apex/com.android.art/lib64/libart.so (art_quick_osr_stub+27) (BuildId: 1dfb27162fe62a7ac7a10ea361233369)
563565
02-06 14:33:12.997 2016 2016 F DEBUG : #12 pc 00000000003d27ba /apex/com.android.art/lib64/libart.so (art::jit::Jit::MaybeDoOnStackReplacement(art::Thread*, art::ArtMethod*, unsigned int, int, art::JValue*)+410) (BuildId: 1dfb27162fe62a7ac7a10ea361233369)
564566
*/
565-
//JavaScriptCore.JSValueUnprotect(context.context, value)
567+
if !context.released {
568+
JavaScriptCore.JSValueUnprotect(context.context, value)
569+
}
566570
}
567571
}
568572

0 commit comments

Comments
 (0)