-
Notifications
You must be signed in to change notification settings - Fork 927
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
android: Allow redraws and resizes when a Surface
is present
#3897
base: master
Are you sure you want to change the base?
android: Allow redraws and resizes when a Surface
is present
#3897
Conversation
if self.window_has_surface { | ||
if resized { |
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.
Given the asserts above I want to get rid of this double checking, except for handling a user-triggered redraw request.
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.
Shouldn't we also assert if the user triggers request_redraw
while there is no surface?
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.
Since it could be async, I don't want to be that harsh on them - for now.
Perhaps that changes once we wire redraws up to Choreographer
(and perhaps have a default "keep automatically requesting redraws every vsync" mode).
// TODO: Theoretically the wake-up should also be handled when there's no surface | ||
timeout = if self.window_has_surface | ||
&& (self.pending_redraw || self.window_target.proxy_wake_up.load(Ordering::Relaxed)) |
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.
Specifically, a non-pending_redraw
arbitrary wakeup.
// /// `onStart()` - `onStop()` lifecycle, denoting when the app is visible | ||
// TODO: Might use activity_visible for allowing proxy wakeup events? | ||
// activity_visible: bool, | ||
// /// `onResume()` - `onPause()` lifecycle, denoting when the app is actively interacted with | ||
// activity_active: bool, | ||
// TODO: This should be per-Activity (likely analogous to per-Window) state. | ||
window_has_surface: bool, |
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.
I started with these states just to see what would happen, but it's quite common to have:
onStart()
onResume()
NativeWindowCreated
NativeWindowResized
NativeWindowRedrawNeeded
WindowFocusChanged
to1
- ...
WindowFocusChanged
to0
onPause()
NativeWindowDestroyed
onStop()
- (
SaveInstanceState
...)
So keying off of NativeWindowCreated/Destroyed
is our only safe bet.
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 like an improvement so far
abaca14
to
048c9c2
Compare
... and not _just when the activity is active_. [Android's activity lifecycle] denotes that `onResume()` and `onPause()` are called when the activity changes the "active" state (which is separate from the "focused" state) and may _or may not_ be followed or preceded by the `onStart()` - `onStop()` lifecycle which denotes Activity _visibility_. The latter more closely relates to when a surface is present (since when the activity is not active, but still visible redraws and resizes are still possible and expected) but also doesn't exactly represent it. Note that Android fires its `WindowResized` and `RedrawNeeded` callbacks at least once, directly after `InitWindow`, and _should_ (but this is not explicitly documented) never fire again after `TerminateWindow`. Theoretically this isn't the right state to key off of for arbitrary `EventLoop` wakeups via the `Proxy` though. [Android's activity lifecycle]: https://developer.android.com/guide/components/activities/activity-lifecycle
048c9c2
to
f242da9
Compare
... and not just when the activity is active. Android's activity lifecycle denotes that
onResume()
andonPause()
are called when the activity changes the "active" state (which is separate from the "focused" state) and may or may not be followed or preceded by theonStart()
-onStop()
lifecycle which denotes Activity visibility. The latter more closely relates to when a surface is present (since when the activity is not active, but still visible redraws and resizes are still possible and expected) but also doesn't exactly represent it.Note that Android fires its
WindowResized
andRedrawNeeded
callbacks at least once, directly afterInitWindow
, and should (but this is not explicitly documented) never fire again afterTerminateWindow
.Theoretically this isn't the right state to key off of for arbitrary
EventLoop
wakeups via theProxy
though.(PR spun out from #3786)
changelog
module if knowledge of this change could be valuable to users