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

Handle no model argument being passed #1286

Merged
merged 7 commits into from
Oct 30, 2022

Conversation

erenoku
Copy link
Contributor

@erenoku erenoku commented Oct 28, 2022

This PR adds support for starting fj-app with no arguments.

If no model argument is passed or no fj.toml file is present start the UI normally but display a warning and a button to open file picker in the middle of the screen. If the app is in export only mode display no_model_error and exit. The communication between egui and the main event_loop is handled by crossbeam_channels and the Gui struct stores a GuiState to store whether there is a model opened.

@erenoku erenoku requested a review from hannobraun as a code owner October 28, 2022 18:53
@erenoku
Copy link
Contributor Author

erenoku commented Oct 28, 2022

Turns out the libraries gtk-3 or xdg-portal packages are needed to compile the crate RFD. That's why the CI jobs are failing. I think we can use the CI file of that repository to make our CI tests work.

@hannobraun
Copy link
Owner

Thank you, @erenoku! I don't have time to review right now, but I'll take a look soon. Tomorrow, if I can, or next week, if not.

Copy link
Owner

@hannobraun hannobraun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @erenoku! This is great!

I've taken a close look at the code and left some comments. In addition, there are a few more problems that need to be addressed before this is ready to merge:

  • The CI build needs fixing, as you note. It looks like the CI file you linked doesn't need to install anything for XDG Desktop Portal, so the build might fix itself, if we use that instead (I've also left a comment on that topic).
  • It's not up-to-date with the main branch and needs a rebase. There are no conflicts, so I could do this automatically when merging, but I'd like to see how this looks together with Fix text of status messages looking jagged #1275, and if maybe a similar fix is required for the new UI element.
  • There are some compiler and Clippy warnings that need fixing. Those would fail the CI build, once the other CI issue is addressed.
  • There's a panic when quitting the application:
    thread '<unnamed>' panicked at 'Expected channel to never disconnect: RecvError', crates/fj-host/src/evaluator.rs:22:18
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    I'm actually not sure if this is new, or if it was there before. In any case, it would be nice to get it fixed, but it's not critical.

crates/fj-host/src/host.rs Outdated Show resolved Hide resolved
crates/fj-window/src/run.rs Outdated Show resolved Hide resolved
crates/fj-viewer/src/gui.rs Outdated Show resolved Hide resolved
crates/fj-window/src/run.rs Outdated Show resolved Hide resolved
crates/fj-app/src/main.rs Outdated Show resolved Hide resolved
crates/fj-viewer/Cargo.toml Outdated Show resolved Hide resolved
@erenoku
Copy link
Contributor Author

erenoku commented Oct 29, 2022

Thanks for the feedback.
I think all the issues are fixed now but I could not reproduce the panic when quitting the application. If it consistently happens on your machine could you upload the backtrace.

Comment on lines 27 to 31
/// Event that are passed between the event_loop and gui
pub enum GuiEvent {
AskModel,
LoadModel(PathBuf),
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing GuiEvent outright is perfectly fine, but just for the record, I think it would have been slightly nicer to keep a struct AskModel; and a struct LoadModel(PathBuf); around, to make those Sender/Receiver types below a bit more descriptive (Sender<AskModel> instead of Sender<()>, for example).

But this is only a minor thing! Just mentioning it for future reference.

Comment on lines +361 to +362
#[cfg(target_arch = "wasm32")]
todo!("Picking folders does not work on wasm32")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (and the other cfgs) aren't great, but I can't think of a better way to do it right now. Maybe the file picking feature should move out of fj-viewer and into fj-window or fj-app? No idea. We'll figure it out at some point!

crates/fj-host/src/host.rs Show resolved Hide resolved
crates/fj-window/src/run.rs Outdated Show resolved Hide resolved
@hannobraun
Copy link
Owner

Hmm, looks like GitHub is being weird and sent my review comments before I actually wrote the main review itself. Please stand by, I'll finish that shortly.

Copy link
Owner

@hannobraun hannobraun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes, @erenoku!

I've left some comments, but all of those are about minor things. I'll merge this right now. Feel free to create a follow-up PR with additional changes, if you want, or don't 😄

I think all the issues are fixed now but I could not reproduce the panic when quitting the application. If it consistently happens on your machine could you upload the backtrace.

There is no backtrace, beyond the file/line from the panic message, as that panic happens in the root scope of one of the threads.

If you're not seeing it, don't worry. It's not critical anyway, and it'll be much easier for me to debug, since I can reproduce it consistently. I've made a note about that, and will take a look next week, mostly likely.

@hannobraun hannobraun merged commit 6e3f5b3 into hannobraun:main Oct 30, 2022
@erenoku erenoku deleted the handle_no_model branch October 30, 2022 09:49
@hannobraun
Copy link
Owner

I fixed the panic I was seeing: #1296

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