eclipse-theia / theia

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript.
http://theia-ide.org
Eclipse Public License 2.0
19.38k stars 2.45k forks source link

Theia app is not loading while minimized at startup #13798

Open rschnekenbu opened 3 weeks ago

rschnekenbu commented 3 weeks ago

When minimizing the window of a Theia based electron application at startup, the loading of the application seems suspended until the window is restored. It can be expected here that the window is still loading despite being minimized.

msujew commented 3 weeks ago

I believe this is a general Theia frontend issue, it's actually fairly easily reproducible in the browser version as well: I've noticed that if I restart the backend and have the frontend open in an inactive tab, it only actually loads the frontend when I switch to the browser tab.

tsmaeder commented 4 days ago

I tried to reproduce this, but could not. Is there a particular sequence of actions to make it happen?

rschnekenbu commented 4 days ago

I could reproduce on my side on Linux, using Theia IDE. I start the application from the command line. In some conditions, I get the splash screen and the main window showing at the same time. If I minimize the main window, the log in the console is stopped, and there won't be anything showing in the main window. The splash screen remains on the screen.

In some other conditions, I don't have the main window showing, only splash screen is displayed. But I can't figure out yet what are these conditions.

rschnekenbu commented 4 days ago

Sample video from stalled start https://github.com/eclipse-theia/theia/assets/3964263/a362a6f9-da51-4cf3-8ae5-2612ddde45b4

tsmaeder commented 4 days ago

it only actually loads the frontend when I switch to the browser tab.

Yes, but it does load it, so why wouldn't it in the electron case? On my side, I can't reproduce this on Windows, even if I turn off the splash screen configuration.

tsmaeder commented 4 days ago

@rschnekenbu "this video can't be played because the file is corrupt" 🤷

rschnekenbu commented 4 days ago

@tsmaeder, I can open the video on chrome (and edge), but not from firefox. On firefox, I get the same corrupted file error :shrug:

tsmaeder commented 4 days ago

Google reveals it's well known compatibility problems with ffmpeg encoding and Firefox. Why can't we just all get along?

tsmaeder commented 4 days ago

@rschnekenbu while I can use chrome for this instance, it would be nice if you fixed your setup so folks are not forced to use Chrome. Also: If I look at the video, the UI seems to come up alright at the end. What's the problem?

rschnekenbu commented 4 days ago

Definitely, I will check for other software options for recording video, convert the video or switch to another format. I found this issue about Kazam mp4 encoding: https://support.mozilla.org/mk/questions/1379414.

For the video, until I restore the window, the app is not loading. The log also does not show any progress. As soon as it is displayed again, the loading process seems active, new events are logged, etc. This looks like we need to keep an eye on the app to get it starting, if not, it will get lazy. After all, we get a running tool, but it is surprising that it stalls when minimized. I would expect the load process to be independent of the tool being visible or not.

tsmaeder commented 4 days ago

O.K. so the title slightly misleading. I'll change it, if you don't mind.

tsmaeder commented 4 days ago

@msujew for the browser case, I think this is normal behavior. As for the electron case, there are two things we'll have to look at:

  1. Make sure we turn off backgroundThrottling when constructing our browser windows
  2. Look at our uses of requestAnimationFrame()': we should only use that to orchestrate actual on-screen behavior. not as substitute forsetTimeout()`. See https://github.com/electron/electron/issues/9567
tsmaeder commented 3 days ago

Turning off background throttling definitely seems to help. However, sometimes Theia still stops loading for a couple of seconds when starting up. The suspicion from the log is that this happens while restoring the layout. I'm currently experimenting with turning `request

tsmaeder commented 3 days ago

Turns out (aka experiments show) the culprit for the delay seems to be in split-panel.ts#animationFrame(). Trying to understand the case.

tsmaeder commented 3 days ago

So...it seems that requestAnimationFrame() is called roughly once per second when the Window is minimized, independent of background throttling. The split panel has an optional animation to make the side panels slide in. My first approach would be to use the page visilibility API to skip the animation when the page is not visible. Turns out though that the page is considered visible with the background throttling turned off. \<sigh>. I'll try out what the animation looks like with setTimeout().

tsmaeder commented 3 days ago

The animation looks fine with "setTimout()".