YuzuJS/setImmediate

simple two question

hopehopehope opened this issue · 2 comments

This is not really an issue (in the sense of that somethings wrong with the code). Rather I have two questions and would appreciate some insight if somebody can give it. thank you.

  1. I am concerned with the runIfPresent thing. I experience that on Firefox 23 it happens that really there sometimes is the case currentlyRunningATask is actually still set to true. How can this ever actually happen. I thought that that (discarding the case of WebWorkers) Javascript guarantees that there is only one thing at a time executing which will be able to run until the end. As it is I cannot see the case or reason why/when it would occur that runIfPresent is executed while still having not finished execution the task from last time. This I assume could at best only happen when I use the function called via setImmediate to forcefully call runIfPresent. Anyway in Firefox (my version is 23) when I do some
    window.setImmediate(function(){alert("hello_1");}
    window.setImmediate(function(){alert("hello_2");}
    window.setImmediate(function(){alert("hello_3");}
    it really is happening that the currentlyRunningATask. I fear this might still be one of the oddities related to crazy firefox way to do alert stuff. (http://stackoverflow.com/q/16987893/1711186)

  2. It seems using "canUsePostMessage" generates a message window.postMessage which will trigger an "message" even for the only eventuallly attached callback onGlobalMessage. This does not make a problem there (as the posted message is empty and hence does nothing there).

For any help I am happy, thanks

I agree that it should never happen, but indeed it's an issue with alert breaking the run-to-completion semantics of JavaScript, from what I understand. It kind of sucks.

And yes, indeed the canUsePostMessage check does post an empty message... I guess that's kind of an annoying side effect :(.

Many thanks for the answer domenic. This alert run-to-compition issue sounds interesting, maybe I will find some background and understanding of it. I really sucks.

Thanks for responding also to the second question with the canUsePostMessage.