-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Reactive Rendering #2662
Merged
Merged
Reactive Rendering #2662
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hecrj
added
feature
New feature or request
performance
widget
rendering
shell
change
addition
labels
Nov 4, 2024
... and fix the redraw queue logic in `iced_winit`.
If we do not request it, macOS does not get any `RedrawRequested` events. Shouldn't `winit` [take care of this]? Probably a bug. [take care of this]: https://docs.rs/winit/0.30.5/winit/event/enum.WindowEvent.html#variant.RedrawRequested
hecrj
force-pushed
the
reactive-rendering
branch
from
November 5, 2024 22:53
d371feb
to
03bffe3
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes the runtime to only perform a redraw of the user interface when either an
update
occurs, or a widget explicitly requests it.Currently,
iced
renders all the time unconditionally on every runtime event. Effectively, this means that when you move your mouse around in aniced
application, the runtime can easily draw hundreds of identical frames—wasting plenty of resources.The changes here make both the runtime and the built-in widgets aware of their last status when drawn, and only request a redraw when needed. This should normally translate to a lower CPU and (specially) GPU usage when interacting with most applications.
As a consequence, the
Widget
andOverlay
contract now require implementors to explicitly request redraws when necessary. Most of the time, this entails some kind of "diffing" during event processing to figure out if the widget state has changed.This new feature is enabled by default but, since it makes widget implementation more difficult and may not make sense for highly dynamic applications, a user can opt out by enabling the
unconditional-rendering
feature; which restores the old behavior.Related important breaking changes include:
Widget::on_event
does not return anevent::Status
anymore. Instead, a widget can capture an event by callingShell::capture_event
. Since widget logic is generally quite imperative, this paradigm fits better and is also more consistent with other shell-related logic.Widget::on_event
has been renamed toupdate
.Program
both forcanvas
andshader
now return awidget::Action
, which can be leveraged to either publish a message or request a redraw, and also event capturing.Event
types forcanvas
andshader
have been removed. They now simply use the foundationalcore::Event
type.