-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Improve initial model loading message #1431
Comments
I'd like to work on this one if it's not already in someone's queue. Either way, I have some questions that would help me understand the code better.
|
I'm not aware of anyone working on this, so feel free to take it, @zthompson47!
I think the race condition would go something like this:
I think this is extremely unlikely (if it's possible at all), but it's also easily avoided by just starting to watch first, then loading for the first time.
This is in fact the default thing that happens when you start Comment out
This is just something I'm wondering about, so I'm not sure it would actually be better. I've tried to attack #1327 multiple times in recent weeks. Some of that led to cleanups that I merged. But most of it died in local branches, because I ran into some problem or another and didn't have the time to focus on it. I believe that Integration with winit would be handled by having a single thread be in charge of the As for integration with WASM, I believe we'd be fine, as long as we don't use anything from Tokio or another runtime in |
That makes sense. I was thinking of the equally-unlikely chance of the watcher triggering an update before the initial load, but at least that ends up with an up-to-date compilation.
Yes, that's it. As for the async, I'll take a look at
That's interesting - I'm still a bit confused about how async works in wasm, or maybe I'm just confused about using async without a runtime. Either way, your answers are very helpful and I just need to play around with these things to see how they work. Thanks! |
Sounds good 👍 And don't feel pressured to use async just because I mentioned it. If you think it doesn't make sense, or you simply don't want to deal with it, that's fine!
The important part of what I said about no runtime is "in So if you're right, and we end up needing As for what the in-browser runtime would be, I don't know. I'm sure I saw something that seemed suitable, but I'm not sure what it was. Maybe I'm remembering |
It's starting to click now. I was thinking in terms of a monolithic setup like the well-known learn wgpu tutorial where the whole thing (well, almost) runs either in a native window or the web. Splitting into a workspace with multiple crates, like Fornjot, would allow a more mix-and-match approach I suppose.
I've also seen that, and I guess the idea there is that the rust I'll proceed with all this in mind and see where it goes. |
I came up with a couple of approaches to fix this issue, and both also fix #1327. The 'long-lived' version spawns a host thread that lives outside of the event loop and takes commands from the event loop via a handle (actor pattern). The 'on-demand' version is a simpler approach that spawns an evaluator thread on each new model, like the current design. Both approaches send the I initially wrote the 'long-lived' version and, after thinking it was overkill if the only command is I'd love some high-level feedback about these ideas and suggestions on where to go from here. Each PR needs some cleanup and I'd also like to write some tests before a merge, so I submitted them as drafts. Thanks! |
Thank you, @zthompson47, this is awesome! I haven't had the chance to look at the pull requests yet, and most likely I won't until tomorrow. But I wanted to give you a quick reply to your comment here. I think both approaches sound reasonable, and I'd be happy with either. That said, I agree with your assessment that the long-lived model might be better suited with what we need in the future.
I expect the interaction between GUI and model to become much richer than it is now. #35 (which you mentioned) is one example of that. #13/#241 is another example of where a selection in the GUI changes what we want to see from the model, which might require interaction with the model code. And then there's interactive debugging of the kernel (see #1385, which is a bit vague right now). I don't know what all of that will look like when it comes to fruition, but I do agree that a long-lived thread sounds like the more flexible approach when it comes to implementing stuff like that. Again, thank you @zthompson47! I'll have a look at the pull requests tomorrow, and I'll hopefully have more specific feedback then. |
Here's the status message displayed when first loading a model after starting the app:
It says "change in model detected", even though that isn't the case here. The model was loaded unconditionally, for the first time. It just reuses the same mechanism that is also used for reloading the model after a change was detected, hence the status message. It would be nicer, if an appropriate status message was displayed each time, that explained what actually happened.
The code that governs this is in
fj-host
.Watcher
watches the model for changes. When it detects a change, it triggersEvaluator
. Both of them are wrapped byHost
, which is then used infj-window
to control model loading and to display those status messages in response to the model events. AChangeDetected
event is emitted byEvaluator
every time a model evaluation is triggered, which results in that status message.I've been thinking through how things could be restructured to achieve this. One possibility is for
Watcher
to provide its own channel where it sendsChangeDetected
messages, and those events could be handled by bothEvaluator
and the main event loop infj-window
. Instead of triggering the first evaluation by sending an initial event,Host
could take care of triggeringEvaluator
for the first time, or there could be separateStartWatching
/ChangeDetected
events. Probably, the events produced byWatcher
/Evaluator
would be filtered throughHost
before they are handled infj-window
, sofj-window
just gets a single channel to handle events from.As I'm thinking through this, I wonder if it makes sense to do away with all the threads and just make everything async.
The text was updated successfully, but these errors were encountered: