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

App doesn't display anything until model is fully loaded #1240

Closed
hannobraun opened this issue Oct 20, 2022 · 1 comment · Fixed by #1244
Closed

App doesn't display anything until model is fully loaded #1240

hannobraun opened this issue Oct 20, 2022 · 1 comment · Fixed by #1244
Labels
type: feature New features and improvements to existing features

Comments

@hannobraun
Copy link
Owner

When starting fj-app, it doesn't display anything (not even opening a window) and just hangs, until the model has been compiled for the first time. This is usually not a problem, but when starting fj-app for the first time, it needs to compile not only the model, but its dependencies. This can take multiple seconds and is very noticeable.

This issue can be reproduced with the following steps:

  1. In the repository root, run cargo clean.
  2. Run cargo build -p fj-app to build the app, but not the models. This step is optional, it just makes the delay that compiling the model introduces more obvious.
  3. Run cargo run.

On my computer, the app starts pretty much immediately on the last step (there are currently some wgpu error message that show up immediately), but it takes multiple seconds before it opens a window. Once a window has been opened, there's a status message like "Model compiled successfully in 3.64 seconds!".

On subsequent cargo runs, the window opens much more quickly, and the time it takes to compile the model is much shorter (0.04 seconds is a typical value on my machine for the test model).

I think the following should happen instead:

  1. fj-app should start immediately and display the full GUI.
  2. It should display a status message, that the model is currently being loaded.
  3. Once the model finished loading, it can display the respective status message (already implemented) and show the model.

Some groundwork has been done recently to make displaying the model optional, so I think this might not be that difficult to do. It probably involves re-shuffling some logic in fj-app's main.rs, fj-window's run.rs and possibly fj-host. Also there's been a previous issue in this vein (#1015). The current behavior is either a regression, or that previous issue was never fully fixed (one aspect of it was fixed, the compiler error never being shown).

@hannobraun hannobraun added type: feature New features and improvements to existing features topic: ui labels Oct 20, 2022
@hannobraun hannobraun added this to the Basic Usability milestone Oct 20, 2022
@hannobraun
Copy link
Owner Author

hannobraun commented Oct 20, 2022

I've been looking into this. One thing I said above is wrong: The app does open a window. I just don't seem to have noticed, because it was transparent.

The problem is that at the beginning of the event loop, fj-window calls Watcher::receive_shape:
https://github.com/hannobraun/Fornjot/blob/02efc43e64f33bf0131be07d58259a7b8ba674bd/crates/fj-window/src/run.rs#L53

That checks if the model has changed and compiles it then and there:
https://github.com/hannobraun/Fornjot/blob/02efc43e64f33bf0131be07d58259a7b8ba674bd/crates/fj-host/src/lib.rs#L331-L333

Which blocks the event loop until the model has finished compiling. This doesn't just happen on the initial re-compile, but on every subsequent one.

This is just the wrong way to do it. winit has a mechanism to inject events into the event loop, and we should use that to compile the model completely asynchronously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New features and improvements to existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant