Closed SrinivasGourarum closed 8 years ago
Thanks for the post :). I've briefed in the last thread. Hopefully that will help you with your issue but if not, feel free to discuss more with us.
Thanks, Limin Zhu Chakra, Microsoft
Thank you. The solution worked for us.
Hi,
There still seems to be an access violation when I enable finalizer callback when creating external object. when I pass "null" in place of finalizer callback, there is no access violation.
JavaScriptValue.CreateExternalObject(new IntPtr(objId), null);// no access viloation
JavaScriptValue.CreateExternalObject(new IntPtr(objId), ExternalCustomObjectFinalizeCallback);//access violation
public static void onExternalCustomObjectFinalizeCallback(IntPtr data) { //notifying the c# about the object to be collected }
Is it again a case of garbage collection? If so, how do we avoid it?
It's possible that ExternalCustomObjectFinalizeCallback is collected by GC. Can you try adding the line to hold on to the finalize callback,
public static readonly JavaScriptObjectFinalizeCallback finalizeDelegate = ExternalCustomObjectFinalizeCallback;
And pass finalizeDelegate to CreateExternalObject?
This seems to do the trick for the most part. I am still looking into a particular scenario which could result in access violation. I will get back if the issue persists.
That was all. I did not encounter any more AVs. Thanks a lot.
Could you please brief on how the issue https://github.com/Microsoft/Chakra-Samples/issues/4 got resolved. We are facing a similar issue. There is access violation exception/ engine execution exception whenever there is a call on UI thread and succeding calls on the JS thread results in exception.