David Bruant (2013-08-08T14:40:41.000Z)
domenic at domenicdenicola.com (2013-08-12T05:30:41.561Z)
Le 08/08/2013 16:03, Domenic Denicola a écrit : > To me the answer always seemed obvious: use the slow-script dialog. What am I missing? For a while loop or just too long running script, this dialog may break your JS stack *anywhere*, stop at any instruction. It may not be always easy to recover as it may break all sorts of invariants your code relies on. It's exactly like OS thread pre-emption. But there is not really a cleaner way. Let's say a spec requires window.asap to prompt a slow script dialog if abused. I imagine that all or part of the event queue is flushed (this needs to be standardized too). This also breaks program invariants in all sorts of ways. Let's make guesses. Let's say a browser decides that "script too slow" dialog is poor UX and that it wouldn't be such a big deal to insert here and there handling of click events... Suddenly, website X (that abuses microtasks) runs better on browser Y than Z. This might encourage Z to break the "microtask contract" as well. Once it's at it, Y, might just add 4ms clamping because delaying a microtask sounds more friendly than randomly breaking code invariants. Small delays between (micro)task sounds like a local maximum it's hard to get away from unfortunately :-( > I assumed by "implementation" you meant "promise implementation," as in the quoted paragraph. I'd much rather have the browser implementation maintain it. I meant "browser implementation", sorry for the confusion. > Why are implementers OK with giving us postMessage/MessageChannel but not setImmediate? Why are they OK with giving us MutationObservers/Object.observe but not "`window.asap`"? I feel we just have to wait until these are abused and we'll see the clamping solution coming back. Exactly like setImmediate would be forced to if widely (and eventually mistakenly) used. Maybe we can add the same feature with a different name every 5 years ? :-) We need to randomly choose the name so that people don't prolyfill :