-
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
Refactor epi::Frame #673
Comments
Just want to drop a note here that I would find this especially useful with the applications I'm writing. I go out of my way to make sure that any long-running jobs aren't on the same thread as the GUI, but often these are jobs computing or updating raster images to display. Currently I kind-of-sort-of work around this by having those long-running image processing jobs (taking tens of seconds in my case) mark the image as "ready" for a texture update when they're done, on a thread-safe bool variable. Then the GUI code checks that variable on every update, and transfers the image to a texture when It works okay, since the long-running work happens on another thread. But even just transferring the image data to a texture takes a small bit of time (these are very high-res images) and makes the gui hiccup whenever it happens. Being able to allocate textures from other threads would both simplify the code a lot and eliminate the hiccups. |
epi::Frame
contains methods for controlling the surrounding app (i.e. the native winit window or the web browser). At the moment this includes allocating texture, quitting and changing the window size. We may soon also be able to toggle decorations, toggle fullscreen and request user attention.At the moment
Frame
is only available inApp::update
which means you cannot call this methods from a separate thread.I think it would be useful if we could change
App::update
(andApp::setup
) from taking a&Frame<'_>
to taking a&Arc<Frame>
. A user could clone thisArc
and send to a background thread. This would allow users to e.g. start HTTP requests, and when finished request user attention, allocate a texture, or similar.Perhaps we want something like
struct FrameRef(Arc<Frame>)
orFrameRef(Arc<Mutex<Frame>>)
to encapsulate this in a nicer way (similar toegui::CtxRef
vsegui::Context
).We could then replace the current
repaint_signal
with just a normal call (frame.request_repaint();
, perhaps more appropriately namedrequest_update
).The text was updated successfully, but these errors were encountered: