Reputation: 11491
We've developed our code using Ractjs 3, JavaScriptEngineSwitcher, and Microsoft.ChakraCore.
Once in a while my application took some seconds to load a page but I didn't have any errors on my application log so I decided to diagnose it with DebugDiag tools on windows server. Then I found several ThreadAbortException related to Chakra.
System.Threading.ThreadAbortException
Thread was being aborted
System.Threading.WaitHandle.WaitOneNative(System.Runtime.InteropServices.SafeHandle, UInt32, Boolean, Boolean) System.Threading.WaitHandle.InternalWaitOne(System.Runtime.InteropServices.SafeHandle, Int64, Boolean, Boolean) System.Threading.WaitHandle.WaitOne(Int32, Boolean) JavaScriptEngineSwitcher.ChakraCore.ScriptDispatcher.StartThread() System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) System.Threading.ThreadHelper.ThreadStart()
20% of all threads have:.
Entry point ChakraCore!JsDisposeRuntime+12a44
Call Stack
ntdll!NtWaitForMultipleObjects+14
KERNELBASE!WaitForMultipleObjectsEx+ef
ChakraCore+bd824
ChakraCore!JsDisposeRuntime+26ee
ChakraCore!JsDisposeRuntime+12aa1
kernel32!BaseThreadInitThunk+14
ntdll!RtlUserThreadStart+21
Also another 20% have:
Entry point ChakraCore!JsDisposeRuntime+12a44
Call Stack
ntdll!NtWaitForMultipleObjects+14
KERNELBASE!WaitForMultipleObjectsEx+ef
ChakraCore!JsGetPropertyIdFromName+1673
ChakraCore!JsGetPropertyIdFromName+1410
ChakraCore!JsGetPropertyIdFromName+993
ChakraCore!JsDisposeRuntime+12aa1
kernel32!BaseThreadInitThunk+14
ntdll!RtlUserThreadStart+21
Upvotes: 1
Views: 138
Reputation: 1984
Are you correctly adding references to JavaScriptValues that you are processing on the native side? If not, you'll have memory corruption of which one of the symptoms would be crashes on disposal of the ChakraCore context/runtime.
For an example of how to guard against this class of issues, see React Native Windows' real-world example of how to safely embed ChakraCore (while still being performant).
Upvotes: 0