-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Graceful exit from web #1650
Graceful exit from web #1650
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a quick read-through. Thanks for working on this!
Did you try returning the handle from |
That was planned at first, but I was not sure I understand how it will be managed by garbage collector, but looks like its fine. I'll do it, but cant find time for now. |
714e3d1
to
58c88ca
Compare
I've made this dont use global variable |
5f83168
to
468eb84
Compare
pub struct WebHandle { | ||
handle: Arc<Mutex<AppRunner>>, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This WebHandle
wrapper should be moved into eframe
instead so that all eframe
users can stop their instances!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I tried to make egui embeddable, not just run in whole document. WebHandle is extensible. You have handle in js and you can call some methods to interact with egui app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but what is the point of defining WebHandle
in the example app? I don't see stop_web()
being used anywhere. Is it dead code? Should docs/index.html
store the handle as a demonstration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well. Ok. I'll create another wrapper in eframe
Thanks ❤️ |
Btw, what do you think on adding I need it to get original App from WebHandle |
3814ad1
to
4d0957b
Compare
Fixed Web, IntervalHandle, looks like most of issues. Quick checked and seems everything is fine |
5af9ede
to
1a4f0b0
Compare
1a4f0b0
to
85568ca
Compare
squashed and rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Still needs a line in eframe/CHANGELOG.md
noting the breaking changes (in particular the need to add body { height: 100%; width: 100% }
in the CSS).
All lines in the changelog should link to the relevant PR, and so it would be great if the PR description could be updated with:
A) breaking changes (things all users must do when updating eframe
)
B) a short summary or example of what the new features enable (having two egui instances in the same web page), and how to achieve it (does the user need need to call stop_web
form JS when deleting a canvas
with eframe running in it?)
pub struct WebHandle { | ||
handle: Arc<Mutex<AppRunner>>, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but what is the point of defining WebHandle
in the example app? I don't see stop_web()
being used anywhere. Is it dead code? Should docs/index.html
store the handle as a demonstration?
thanks for the rebase, but please don't squash - it is easier to follow changes via commit history. I always squash when merging anyway, so the history will still end up clean! |
Co-authored-by: Emil Ernerfeldt <[email protected]>
got it |
it works in scenario where egui app is just a canvas in normal web page. I'll create another page |
Well, that's exactly what the web-demo in |
I mean we need html with some button to stop app |
Added page with stop button on http://127.0.0.1:8888/multiple_contexts.html |
|
||
</html> | ||
|
||
<!-- Powered by egui: https://github.com/emilk/egui/ --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
With this PR egui could be running as a part of web-app and stop and start again without resource leaks(I hope)
Fixes #1642
You need to update your CSS with
html, body: { height: 100%; width: 100%; }
!