New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace timeout/interval functions by Node ones #2261
Conversation
d754f70
to
3c89029
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
I used this approach to replace all of them at once, but if we prefer to go to a more quirurgic one, I can replace only the ones that we want to change, for example the flashing one. |
I think replacing all usages (which isn't that many since we are using our own abstraction in the UI), or rather all of them where this is wanted, since some UI delays might work out better if kept, is a better long-term solution. |
If this is the only difference a single implementation is preferred and can be refined should issues arise of this. |
Even this is not consistent - under linux (Ubuntu) the pausing does not happen. |
Good point. So we need more testing on the implications of this RFC on different platforms (including Android) |
@haslinghuis: Not what I meant to say, and not sure we need more testing - if we trust the node functions to work, then switching to use them globally for all uses in NW.js should be fine. The crux is just that Cordova will need special treatment. So I guess it's again a question of introducing a wrapper, vs. the monkey patching that is proposed in the pull request. |
Monkey patching or overriding a function. Stackoverflow is divided here 🤣 But if a wrapper could make this better this wouldn't be that hard to add. |
Then the best way seems to be to override a monkey patched function. 😝 |
Are you sure about this? Is strange. The pausing happens only while flashing, not while erasing for example, and can be replicated easily under Windows minimizing the Configurator window. Maybe the Sorry, my English is not too good, and I don't understand exactly what I must to change. If I have understood, we prefer to go the surgical way, and change only the timeout related with the flashing? |
@McGiverGim: Interesting observation: In linux, when using 10.7.0 (based on NW.js 0.44.2), flashing stops when minimised. When using 10.8.0 from So it looks like at least in linux something has changed to make this a non-problem in the latest version. |
Is strange. My tests were done under Windows and latest master, so in Windows the problem remains with newer version. Then better to change only where flashing? In this way will be a little change to fix the issue, and maybe in a future we can get rid of it. |
@McGiverGim: Potential alternative solution: If this is in the process of being changed (fixed?), then maybe in a newer version of NW.js this will work in Windows as well? I don't have Windows, but can you give NW.js 0.49.1 (the latest) a spin to see if this works? |
Tested, it does not fix the issue. It stops the flashing while minimized or out of focus. |
I have tested a VM with Ubuntu and I can confirm your description: under Linux the problem do not exist. |
I've been thinking about this, and the following statements seem to apply:
One potential improvement might be to change the method prototype instead of the object method, i.e
This will make the switch work even for new windows, but I am not sure if this will work for the initial Window, so this needs testing. |
I will test it soon. I don't have too much time lately. |
@mikeller tested the approach with prototype and does not work. Maybe it needs to be done in other place or maybe related that this methods belong to the WindowTimers interface that is inherited by Window? I don't know. I did it like this, replacing the code of this PR, maybe I did something wrong? |
Thanks for testing - the problem here seems to be that this is only called when the |
Fixes #2170
This is an ugly hack to replace the standard
setTimeout
andsetInterval
functions by their equivalents in the Node api (where available).The biggest difference between both is that the Node one does not pause the execution when the windows is out of the focus, letting us continue flashing for example or any other operation that depends of this kind of timers.