Ok, seems that I CAN call js functions from within RequestInterrupt, things
seem to work.
I guess I'm confused what this means in that case: "Registered |callback|
must not reenter interrupted Isolate."
On Monday, 21 April 2025 at 17:41:21 UTC+1 jmr wrote:
> I'm porting an application that is using SpiderMonkey for embedding, and I
> have a few questions.
>
> One of the things my application does is, it allows user (in javascript)
> to register for events:
>
> func handler(...) { {}
> registerEventHandler("evetName", handler);
>
> In C++, I then store these handlers to be called later once the event
> arrives.
>
> Once the event arrives (different thread than isolate is running on), I
> store it in a pending event list for the runtime (isolate), I then
> call JS_RequestInterruptCallback which interrupts the execution of the
> runtime (isolate), and drops into my C++ interrupt callback.
>
> From my C++ callback, I check for pending events, and call the user
> provided functions (re-entering the isolate) delivering the events, and
> resume execution to the user.
>
> Seems that with v8, I can get quite close to this, except
> isolate->RequestInterrupt does not allow re-entering the isolate/calling
> user code, making this not work.
>
> I tried using EnqueueMicrotask but seems those are never delivered
> automatically unless the script stops, or I call PerformMicrotaskCheckpoint
> (which then ends up on the wrong, calling thread)
>
> I tried posting a task to the platform
> (platform->GetForegroundTaskRunner(isolate)->PostTask), but given the
> script is long lived, I don't think this ever gets delivered.
>
> I tried using Locker(isolate) + Isolate::Scope(isolate)
> + isolate->GetCurrentContext() from the event thread, and then calling the
> callbacks, but this crashes non-deterministically, sometimes with "Invoke
> in DisallowJavascriptExecutionScope".
>
> Any guidance is appreciated.
> Thanks.
>
>
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/v8-users/12e0876e-96b5-451f-8c88-11b4c4d8efd3n%40googlegroups.com.