-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
Use of requestAnimationFrame means activities cannot take place in background #392
Comments
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗 |
I just want to say that as a user I hit this issue many times (often when leaving a binder tab loading in the background) and would like to thank you for investigating and providing a proposed solution. I agree that |
The background issues might not be as bad as I would anticipate, since apparently they are throttled to 1 sec in most browsers. |
As the automatic update above says, I created a draft review of the potential fix here: #395 If this is the right stage in the process for this (particularly given the scope of the change) I am happy to promote it from “draft” to “ready to review” but for now I just wanted to get it out there. |
@fcollonval notes that this should probably also go back to 1.x, and the fix I have applies cleanly there. |
Description
We run a JupyterHub instance on top of Kubernetes. Launching a new JupyterLab notebook instance takes a minute or so, meaning users often switch to another tab and do something else while waiting for the notebook to load. However, other setup activities, like loading notebook files, starting kernels, and more does not actually take place until the user switches back. This may take another minute or two (during which they are likely to switch away again).
I traced this delay back to the fact that Lumino uses
requestAnimationFrame
to defer tasks. This does not run while the tab is in the background:lumino/packages/polling/src/poll.ts
Lines 15 to 18 in 2d9b7aa
Reproduce
The full user experience won’t reproduce locally, but you can get a flavor of it and see the symptoms:
jupyter lab --no-browser
)The long wait ↹’d in this screenshot is the time that I had another tab open.
Expected behavior
I would expect my session to restore itself and other things to load even if I had my tab open in the background.
Caveats and ideas
There probably is existing code that depends upon the existing “don‘t do work in the background” behavior. These are a few ideas for how to deal with that, listed from what seems (from my outsider’s perspective) from better to worse/harder:
setTimeout(...)
if arequestAnimationFrame
has not happened yet, and then once the first animation frame has been requested, use that instead.setImmediate
is an option ifrequestAnimationFrame
does not exist.setTimeout
(with no timeout) is the standard version of that and it could be used.Context
The text was updated successfully, but these errors were encountered: