-
Notifications
You must be signed in to change notification settings - Fork 7
Provide custom fallback instead of setTimeout #50
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
Comments
This project is based on the popular JS https://github.com/YuzuJS/setImmediate So, it must be good enough? |
I think the problem is that the unfair promise based executor will cause performance problems of a different and less diagnoseable sort. We've seen this a few times in various guises. At least |
Thanks for your answers. Agree that the promise based executor is not really desirable. Though depending on the case, it might be a better performing fallback then setTimeout. But of course not generally correct. My question is probably more: how often will the fallback actually happen? And should we have a way to detect it in the application using this project - so they can emit a warning to their users? |
Well, Notably, So ... :) The |
True, support seems to be quite widespread. And good point on comparing it to promise support. I am just afraid and want to make sure, I do not end up with using |
I mean, what do you want to do in that situation? Since in those situations it seems likely that Note that even the default EC in Scala.js also falls back to If you're looking for a mechanism to detect old, unsupported browsers for your application, it seems you should do exactly that. Which I think is out-of-scope for this project. |
I would probably think about warning the user of degraded performance. Detecting outdated browsers could be an alternative approach to that indeed. |
Right. I guess my point is, your concerns are almost definitely broader than what this particular project does or does not. For example in outwatch/outwatch#605 you switched to using microtasks for snabbdom patching. What happens if neither |
Right, outwatch does not handle it gracefully if promises are not defined. I thought of falling back to patching synchronously but i am not sure. I guess, this will not be supported for now. And colibri also needs the promise queue. So, you are right: for that use-case i would need a more sophisticated detection :) At least, i got rid of the linked native types to using the MacroTaskExecutor and the scalajs promise executor. But apart from outwatch and apart from the promise queue, I still think it would be useful to at least know when setTimeout is used as a fallback in this project. |
Ok, that's fair. Adding to the API is a bigger question, but I suppose adding a |
I think that would be a good solution. I like it! It will make the issue visible :) |
I think this really nails it on the head. The example in the README demonstrates that the worst-case for the Promises-based executor is that the UI will completely stop responding. It is easy to fall into this trap when writing idiomatic Scala, for example in some library that cross-builds for Scala.js without explicitly being designed for it. That's why the MacrotaskExecutor is the right general-purpose default. Meanwhile, the worst-case for the MacrotaskExecutor is that it will be sluggish, for a fraction-of-a-percent of users. If you are very concerned about the 0.2% of users for which a high-performance macrotask polyfill is not available (and not concerned about the 0.2% of users that don't have Promises support either) then you can explicitly run and test that code on the Promises-executor instead. Ideally, this should be scoped to small regions of your application that you are confident will not create serious fairness issues. |
I think, you are right. I was also reflecting on this topic in the past days and now agree that it is actually fine as it is. Thank you so much for all the answers and interest in this topic 👍 |
I am bit afraid about the fallback to
setTimeout
. This would cause serious performance issues. In most casespostMessage
should be there in browsers and we have setImmediate in nodejs. But if not, i might decide to fallback to the unfair promise queue or throw an exception depending an the use-case.Should we make this configurable or will it "never" happen? :)
The text was updated successfully, but these errors were encountered: