Skip to content

Conversation

@gspencergoog
Copy link
Contributor

@gspencergoog gspencergoog commented Mar 22, 2023

Description

This adds AppLifecycleListener, a class for listening to changes in the application lifecycle, and responding to requests to exit the application.

It depends on changes in the Engine that add new lifecycle states: flutter/engine#42418

Here's a diagram for the lifecycle states. I'll add a similar diagram to the documentation for these classes.

Application Lifecycle Diagram

Related Issues

Tests

  • Added tests for new lifecycle value, as well as for the AppLifecycleListener itself.

@flutter-dashboard flutter-dashboard bot added a: text input Entering text in a text field or keyboard related problems d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos documentation framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Mar 22, 2023
@gspencergoog gspencergoog changed the title Add AppLifecycleListener, and support for application exit. Add AppLifecycleListener, with support for application exit handling Mar 22, 2023
@gspencergoog gspencergoog changed the title Add AppLifecycleListener, with support for application exit handling Add AppLifecycleListener, with support for application exit handling Mar 22, 2023
@gspencergoog gspencergoog force-pushed the app_lifecycle_listener branch from bf62242 to c966a53 Compare March 22, 2023 20:49
@gspencergoog gspencergoog force-pushed the app_lifecycle_listener branch 3 times, most recently from a462310 to 6dc167c Compare March 29, 2023 22:26
@gspencergoog gspencergoog force-pushed the app_lifecycle_listener branch 7 times, most recently from 5d2beec to 7559092 Compare April 10, 2023 18:25
@gspencergoog gspencergoog force-pushed the app_lifecycle_listener branch 3 times, most recently from d649682 to b062fa4 Compare April 13, 2023 20:10
@gspencergoog gspencergoog force-pushed the app_lifecycle_listener branch from b062fa4 to dfb1e04 Compare April 17, 2023 23:44
@gspencergoog gspencergoog force-pushed the app_lifecycle_listener branch 5 times, most recently from 486c31a to 94dff71 Compare May 2, 2023 22:21
auto-submit bot pushed a commit to flutter/engine that referenced this pull request May 26, 2023
…tate. (#40542)

## Description

This adds app lifecycle notification for macOS and Linux, and adds a new `hidden` state to the `AppLifecycleState` enum.

To be functional, this needs a corresponding framework change: flutter/flutter#123274

## Related Issues
 - flutter/flutter#30735

## Tests
 - Added tests for state changes.
@gspencergoog
Copy link
Contributor Author

Okay, I think this is ready for another look, @goderbauer.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my own understanding (since this returns a Future): Am I allowed to delay responding to this for however long I want? Or do platforms impose a timeout here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, you can delay as long as you want and they will wait for you to respond. I suppose they might put up a system dialog saying that you took too long and ask if your app should be forcefully killed, but that won't affect the way the API works from the developer's point of view.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I think about it, the stranger I find it that this optionally takes in a binding. I don't think we use this pattern elsewhere and would expect tests to just install their own (global) custom binding if they need some custom behavior. I also can't think of a testing scenario where you'd really need a custom binding here... I think all the tests you're adding in this PR would pass if you wouldn't pass in the binding manually....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, This was a suggestion that @Hixie had early on. It does seem convenient, and in normal usage it doesn't make any difference. It would be less complex to not have it, though.

@gspencergoog gspencergoog force-pushed the app_lifecycle_listener branch from 865be95 to 9f90101 Compare June 8, 2023 00:44
@gspencergoog gspencergoog added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 8, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 8, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Jun 8, 2023

auto label is removed for flutter/flutter, pr: 123274, due to - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@gspencergoog gspencergoog added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 8, 2023
@auto-submit auto-submit bot merged commit a280346 into flutter:master Jun 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 9, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jun 9, 2023
flutter/flutter@6e254a3...da127f1

2023-06-09 [email protected] Updated material button theme tests for Material3 (flutter/flutter#128543)
2023-06-09 [email protected] Roll Flutter Engine from cb93477008d6 to 93afba901b3b (2 revisions) (flutter/flutter#128573)
2023-06-09 [email protected] Improve defaults generation with logging, stats, and token validation (flutter/flutter#128244)
2023-06-09 [email protected] [testing] Make the FLUTTER_STORAGE_BASE_URL warning non-fatal (flutter/flutter#128335)
2023-06-09 [email protected] [flutter_tools] [DAP] Don't try to restart/reload if app hasn't started yet (flutter/flutter#128267)
2023-06-09 [email protected] Roll Flutter Engine from 8f9e608d39ab to cb93477008d6 (3 revisions) (flutter/flutter#128568)
2023-06-09 [email protected] Replace `MaterialButton` from test classes (flutter/flutter#128466)
2023-06-09 [email protected] Fix `showBottomSheet` doesn't remove scrim when draggable sheet is dismissed (flutter/flutter#128455)
2023-06-09 [email protected] Manual roll Flutter Engine from a5f7d5d75ff2 to 8f9e608d39ab (31 revisions) (flutter/flutter#128554)
2023-06-09 [email protected] Revert "test owners: cyanglaz -> vashworth" (flutter/flutter#128462)
2023-06-09 [email protected] [Android] Bump integration tests using `compileSdkVersion` 31 to 33 (flutter/flutter#128072)
2023-06-09 [email protected] Remove single view assumption from MouseTracker, and unify its hit testing code flow (flutter/flutter#127060)
2023-06-09 [email protected] [flutter_tools] Precache after channel switch (flutter/flutter#118129)
2023-06-08 [email protected] Adding migration guide for Material 3 colors (flutter/flutter#128429)
2023-06-08 [email protected] Add `AppLifecycleListener`, with support for application exit handling (flutter/flutter#123274)
2023-06-08 [email protected] Sliver Main Axis Group (flutter/flutter#126596)
2023-06-08 [email protected] Reduce `_DoubleClampVisitor` false positives (flutter/flutter#128539)
2023-06-08 [email protected] Advise developers to use OverflowBar instead of ButtonBar (flutter/flutter#128437)
2023-06-08 [email protected] Reland "Migrate benchmarks to package:web" (flutter/flutter#128266)
2023-06-08 [email protected] Navigator.pop before PopupMenuItem onTap call (flutter/flutter#127446)
2023-06-08 [email protected] Fix navigation rail with long labels misplaced highlights (flutter/flutter#128324)
2023-06-08 [email protected] Update `chip.dart` to use set of `MaterialState` (flutter/flutter#128507)
2023-06-08 [email protected] Update flutter to dartdoc 6.3.0 and hide Icons implementation from doc pages (flutter/flutter#128442)
2023-06-08 [email protected] Disable blinking cursor when `EditableText.showCursor` is false (flutter/flutter#127562)
2023-06-08 [email protected] [floating_cursor_selection]add more comments on the tricky part (flutter/flutter#127227)
2023-06-08 [email protected] Move RenderObjectElement.updateChildren to Element (flutter/flutter#128458)
2023-06-08 [email protected] Fix PointerEventConverter doc (flutter/flutter#128452)
2023-06-08 [email protected] Roll Packages from a84b2c2 to e13b8c4 (9 revisions) (flutter/flutter#128508)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App c: contributor-productivity Team-specific productivity, code health, technical debt. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants