|
1 | 1 | import { get } from "@ember/object";
|
2 | 2 | import { addObserver } from "@ember/object/observers";
|
3 |
| -import { scheduleOnce } from "@ember/runloop"; |
| 3 | +import { later, scheduleOnce } from "@ember/runloop"; |
4 | 4 | import { default as nwApp, quit } from "nwjs/App";
|
5 | 5 | import { default as nwWindow, setVisibility, setFocused } from "nwjs/Window";
|
6 | 6 | import { argv, parseCommand } from "nwjs/argv";
|
@@ -52,12 +52,11 @@ export default {
|
52 | 52 | // restore window position first (while being hidden)
|
53 | 53 | await windowInitializer( application );
|
54 | 54 |
|
55 |
| - // wait until Ember has rendered the app for the first time (window is still hidden) |
56 |
| - await new Promise( resolve => scheduleOnce( "afterRender", resolve ) ); |
57 |
| - // assume that NW.js doesn't render a white page anymore after the next two frames |
58 |
| - for ( let i = 0; i < 2; i++ ) { |
59 |
| - await new Promise( resolve => requestAnimationFrame( resolve ) ); |
60 |
| - } |
| 55 | + // Wait until Ember has rendered the app for the first time (window is still hidden). |
| 56 | + // Wrap scheduled "afterRender" run-loop queue callback in a new run-loop to ensure |
| 57 | + // that the DOM is fully rendered and no white screen will appear for a few frames. |
| 58 | + // We can't use requestAnimationFrame here due to issue #911. |
| 59 | + await new Promise( resolve => later( () => scheduleOnce( "afterRender", resolve ) ) ); |
61 | 60 |
|
62 | 61 | // wait until the target route is loaded
|
63 | 62 | const routeName = await routingPromise;
|
|
0 commit comments