Skip to content

Commit 7382e93

Browse files
authored
Add scene plugin lifecycle events (flutter#175866)
This PR forwards scene lifecycle events from the SceneDelegate to registered plugins. This PR introduced 3 new public APIs: * `FlutterSceneLifeCycleDelegate` (protocol) - This is the protocol that plugins conform to * `FlutterSceneLifeCycleProvider` (protocol) - This is the protocol that a SceneDelegate can conform to instead of `FlutterSceneDelegate` * `FlutterPluginSceneLifeCycleDelegate` (interface) - This is the class object that a SceneDelegate using `FlutterSceneLifeCycleProvider` can use to forward scene events to The flow of events are as followed when SceneDelegate subclasses the `FlutterSceneDelegate`: * `FlutterSceneDelegate` receives `sceneDidBecomeActive` event from UIKit * `FlutterSceneDelegate` forwards `sceneDidBecomeActive` to `FlutterPluginSceneLifeCycleDelegate` * `FlutterPluginSceneLifeCycleDelegate` loops through each `FlutterEngine` it has and forwards `sceneDidBecomeActive` to the engine's `FlutterEnginePluginSceneLifeCycleDelegate` * `FlutterEnginePluginSceneLifeCycleDelegate` loops through each plugin that conforms to `FlutterSceneLifeCycleDelegate` it has and forwards `sceneDidBecomeActive` to the plugin * `FlutterPluginSceneLifeCycleDelegate` forwards `sceneDidBecomeActive` to `FlutterPluginAppLifeCycleDelegate` using `sceneDidBecomeActiveFallback` * `FlutterPluginAppLifeCycleDelegate` loops through all plugins and calls `applicationDidBecomeActive` if the plugin does not conform to `FlutterSceneLifeCycleDelegate` When using `FlutterSceneLifeCycleProvider` instead of `FlutterSceneDelegate`, scene events are manually forwarded to `FlutterPluginSceneLifeCycleDelegate` by the iOS developer. For example: ```swift class SceneDelegate: UIResponder, UIWindowSceneDelegate, FlutterSceneLifeCycleProvider { var sceneLifeCycleDelegate: FlutterPluginSceneLifeCycleDelegate = FlutterPluginSceneLifeCycleDelegate() func sceneDidBecomeActive(_ scene: UIScene) { sceneLifeCycleDelegate.sceneDidBecomeActive(scene) } ``` Fixes flutter#174398. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 2a109b4 commit 7382e93

55 files changed

Lines changed: 4348 additions & 362 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ci.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4306,6 +4306,26 @@ targets:
43064306
- engine/**
43074307
- DEPS
43084308

4309+
- name: Mac module_uiscene_test_ios
4310+
recipe: devicelab/devicelab_drone
4311+
bringup: true
4312+
timeout: 60
4313+
properties:
4314+
dependencies: >-
4315+
[
4316+
{"dependency": "ruby", "version": "ruby_3.1-pod_1.13"}
4317+
]
4318+
tags: >
4319+
["devicelab", "hostonly", "mac"]
4320+
task_name: module_uiscene_test_ios
4321+
runIf:
4322+
- dev/**
4323+
- packages/flutter_tools/**
4324+
- bin/**
4325+
- .ci.yaml
4326+
- engine/**
4327+
- DEPS
4328+
43094329
- name: Mac_benchmark platform_view_macos__start_up
43104330
presubmit: false
43114331
recipe: devicelab/devicelab_drone

TESTOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@
275275
/dev/devicelab/bin/tasks/build_android_host_app_with_module_aar.dart @mboetger @flutter/android
276276
/dev/devicelab/bin/tasks/build_android_host_app_with_module_source.dart @mboetger @flutter/android
277277
/dev/devicelab/bin/tasks/module_test_ios.dart @vashworth @flutter/tool
278+
/dev/devicelab/bin/tasks/module_uiscene_test_ios.dart @vashworth @flutter/ios
278279
/dev/devicelab/bin/tasks/native_assets_ios_simulator.dart @dcharkes @flutter/ios
279280
/dev/devicelab/bin/tasks/native_ui_tests_macos.dart @cbracken @flutter/desktop
280281
/dev/devicelab/bin/tasks/platform_channel_sample_test_macos.dart @cbracken @flutter/desktop

0 commit comments

Comments
 (0)