When creating a second ChakraCore-runtime, it is not possible to register a prototype object that also was registered in the first runtime. Pseudo-Code:
procedure TMyThread.Execute;
begin
Runtime:=TChakraCoreRuntime.Create();
Context:=TChakraCoreContext.Create(Context);
Context.Activate;
TConsole.Project('Console');
end;
As soon as a second instance is created, an EChakraCoreFatal exception is created with "A hosting API was called with object created on different javascript runtime". Seen with FreePascal 3.x on x64-linux.
My workaround for this is in ChakraCoreClasses.pas, declaring Lock and ProjectedClasses as threadvar, and calling InitializeProjectedClasses/FinalizeProjectedClasses in the constructor/destructor of TChakraCoreRuntime.
I admit I've never tried using multiple runtimes (or destroying one and creating a new one). Good catch. I'll look into it. Thank you for your feedback!
When creating a second ChakraCore-runtime, it is not possible to register a prototype object that also was registered in the first runtime. Pseudo-Code:
As soon as a second instance is created, an EChakraCoreFatal exception is created with "A hosting API was called with object created on different javascript runtime". Seen with FreePascal 3.x on x64-linux.
My workaround for this is in ChakraCoreClasses.pas, declaring Lock and ProjectedClasses as threadvar, and calling InitializeProjectedClasses/FinalizeProjectedClasses in the constructor/destructor of TChakraCoreRuntime.
Apart from that: very nice work!