Skip to content
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

eframe: Don't show window until after initialization #2279

Merged
merged 9 commits into from
Nov 13, 2022
Merged

eframe: Don't show window until after initialization #2279

merged 9 commits into from
Nov 13, 2022

Conversation

LoganDark
Copy link
Contributor

Shortens #1802, but does not completely solve it. This looks to be a step in the right direction, though, and eframe should have been doing this anyway.

Marked as draft because:

  • I have not run cranky since I don't have it installed
  • This could be done better, for example by only showing the window after the first frame has already been painted
  • Ultimately I just wanted to submit this as a first step, even if it's not yet perfect.

@LoganDark LoganDark changed the title Don't show window until after initialization eframe: Don't show window until after initialization Nov 11, 2022
Shortens #1802, but does not completely solve it
@emilk
Copy link
Owner

emilk commented Nov 11, 2022

I have not run cranky since I don't have it installed

cargo install cranky

@emilk
Copy link
Owner

emilk commented Nov 11, 2022

Thanks for working on this - this seems like a promising avenue to explore!

@LoganDark
Copy link
Contributor Author

I have not run cranky since I don't have it installed

cargo install cranky

I think it's actually cargo install cargo-cranky.

Alright, it passes, and I also ran cargo fmt (which I previously forgot).

Thanks for working on this - this seems like a promising avenue to explore!

I'm going to see if I can delay this until the first frame is already painted. That could eliminate the white flash altogether. A lot of the overhead seems to be glutin context creation which takes 500ms at best (iGPU) or 779ms at worst (dGPU).

This resolves the white flash almost completely, but is a hack. Window
visibility should be derived from the AppOutput, and the first frame
should not be painted before the event loop has processed initial
events.

Working on a better implementation.
@LoganDark
Copy link
Contributor Author

LoganDark commented Nov 11, 2022

The window being shown is now properly delayed until the first frame is naturally rendered. The rendering is not forced / done prematurely, either.

This also makes it possible to do something that you could not do before: keep the window completely hidden by calling frame.set_visible(false) on the first update, in which case it will not be shown at any point.

There is still a very very brief (1 frame?) white flash. Maybe we could show the app on the second frame instead :^).

Marking as ready for review.

@LoganDark LoganDark marked this pull request as ready for review November 11, 2022 20:10
This allows an app to keep the window hidden (never shown) by calling
Frame.set_visible(false) on the first update. This includes a slightly
less nasty hack than the last commit did.

Also fixes an accidental cross-contamination of pull requests.
@emilk emilk merged commit f0f41d6 into emilk:master Nov 13, 2022
@LoganDark LoganDark deleted the white-flash branch November 13, 2022 19:36
emilk added a commit that referenced this pull request Dec 2, 2022
* Don't show window until after initialization

Shortens #1802, but does not completely solve it

* format code

* Present first frame immediately before showing window

This resolves the white flash almost completely, but is a hack. Window
visibility should be derived from the AppOutput, and the first frame
should not be painted before the event loop has processed initial
events.

Working on a better implementation.

* Integrate window showing with AppOutput

This allows an app to keep the window hidden (never shown) by calling
Frame.set_visible(false) on the first update. This includes a slightly
less nasty hack than the last commit did.

Also fixes an accidental cross-contamination of pull requests.

* fmt

* add comments

* add comments

* add comments

* add comments

Co-authored-by: Emil Ernerfeldt <[email protected]>
JohannesProgrammiert pushed a commit to JohannesProgrammiert/egui that referenced this pull request Jan 21, 2023
* Don't show window until after initialization

Shortens emilk#1802, but does not completely solve it

* format code

* Present first frame immediately before showing window

This resolves the white flash almost completely, but is a hack. Window
visibility should be derived from the AppOutput, and the first frame
should not be painted before the event loop has processed initial
events.

Working on a better implementation.

* Integrate window showing with AppOutput

This allows an app to keep the window hidden (never shown) by calling
Frame.set_visible(false) on the first update. This includes a slightly
less nasty hack than the last commit did.

Also fixes an accidental cross-contamination of pull requests.

* fmt

* add comments

* add comments

* add comments

* add comments

Co-authored-by: Emil Ernerfeldt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants