[Webkit-unassigned] [Bug 151482] JSContext Promise resolve tasks too eager, can result in infinite loop

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Nov 22 05:52:57 PST 2015


https://bugs.webkit.org/show_bug.cgi?id=151482

--- Comment #1 from Yusuke Suzuki <utatane.tea at gmail.com> ---
Yeah, this is expected behavior.
Currently, we enable automatic recursive draining at the end of VM.
This is nice for the default behavior.
But sometimes we would like to take more fine-grained control over microtasks.

So, I'd like to propose the following APIs,

1. adding an option to disable automatic draining
2. adding an API that explicitly drains queued microtasks. And it does not drains tasks recursively
3. adding an API that tells us whether tasks are queued.

1:

void JSGlobalContextSetAutomaticMicrotaskDrainingEnabled(JSGlobalContextRef ctx, bool enabled);
bool JSGlobalContextGetRemoteInspectionEnabled(JSGlobalContextRef ctx);

(This style and naming convention is similar to JSGlobalContextSetRemoteInspectionEnabled)
And these APIs are similar to V8's `SetAutorunMicrotasks` and `WillAutorunMicrotasks`.

2.

void JSGlobalContextDrainMicrotasksNonRecursively(JSGlobalContextRef ctx);

This is similar to V8's `RunMicrotasks`,
but while `RunMicrotasks` drains tasks until queue is empty (That causes the same infinite loop pasted in this issue), 
this API only drains microtasks that is queued now.

3.

size_t JSGlobalContextGetQueuedMicrotasksCount(JSGlobalContextRef ctx);

Returns the number of currently queued microtasks.

So, the current behavior will be emulated with 2 and 3 API like,

if (JSGlobalContextGetQueuedMicrotasksCount(vm))
    JSGlobalContextDrainMicrotasksNonRecursively(vm);

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20151122/8cf9cc9d/attachment.html>


More information about the webkit-unassigned mailing list