Skip to content

Commit d12e8e2

Browse files
committed
fix(plugins): retain hidden Apple resume completion and diagnose simulator startup
Rebase the existing hidden media resume fix and its 16 Dart regressions onto the author's current Apple probe base. Preserve true media and JavaScript completion, controller/document ownership and the six-second lifecycle deadline. After two simulator log-reader failures without app checkpoints, capture a bounded raw simctl log stream before app launch and enable verbose drive logs. Wait at most 180 seconds for the first authenticated, identity/pin-checked and saved app checkpoint, while retaining the overall run budget and native failure precedence. No polling or diagnostics run inside quiet windows. 81 focused Python tests pass, including 16 new cases; four behavior regressions fail on the exact old runner. Independent QA approved both source and tests. Native iOS acceptance is still required. Depends-on: #4425 Related: #4475, Otzaria/flutter_inappwebview#57
1 parent f1f1417 commit d12e8e2

5 files changed

Lines changed: 839 additions & 16 deletions

File tree

‎.github/workflows/apple-plugin-activity.yml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
- 'test_driver/apple_plugin_activity.dart'
1414
- 'tool/perf_probe/apple_plugin_activity/**'
1515
- 'test/tool/perf_probe/apple_plugin_activity_contract_test.dart'
16+
- 'test/plugins/services/plugin_apple_media_resume_test.dart'
1617
- 'test/tool/perf_probe/apple_plugin_activity_completion_test.dart'
1718
- 'test/tool/perf_probe/installed_plugin_completion_test.dart'
1819
- 'test/tool/perf_probe/perf_fixture_test.dart'
@@ -52,7 +53,14 @@ jobs:
5253
node --test tool/perf_probe/apple_plugin_activity/test_fixture.mjs
5354
python3 -m unittest discover -s tool/perf_probe/apple_plugin_activity -p 'test_*.py' -v
5455
ruby -c tool/perf_probe/apple_plugin_activity/create_control_project.rb
56+
flutter analyze --no-pub \
57+
lib/plugins/services/plugin_runtime_dispatcher.dart \
58+
test/plugins/services/plugin_apple_media_resume_test.dart
5559
flutter test --no-pub \
60+
test/plugins/services/plugin_apple_media_resume_test.dart \
61+
test/plugins/services/plugin_runtime_dispatcher_lifecycle_test.dart \
62+
test/plugins/services/plugin_runtime_dispatcher_regression_test.dart \
63+
test/plugins/services/plugin_runtime_dispatcher_test.dart \
5664
test/tool/perf_probe/apple_plugin_activity_contract_test.dart \
5765
test/tool/perf_probe/apple_plugin_activity_completion_test.dart \
5866
test/tool/perf_probe/installed_plugin_completion_test.dart \

‎lib/plugins/services/plugin_runtime_dispatcher.dart‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,9 +1231,24 @@ class PluginRuntimeDispatcher {
12311231
}
12321232
if (!isCurrent()) return false;
12331233
if (_suspendsMediaExplicitly) {
1234-
await controller
1235-
.setAllMediaPlaybackSuspended(suspended: suspended)
1236-
.timeout(_nativeLifecycleTimeout);
1234+
final media = controller.setAllMediaPlaybackSuspended(
1235+
suspended: suspended,
1236+
);
1237+
if (!suspended &&
1238+
suspendMode == PluginSuspendMode.eventOnly &&
1239+
!_desiredForegroundKeys.contains(key)) {
1240+
// An offstage WKWebView can throttle the media reply. A one-off JS
1241+
// evaluation takes a WebKit process activity while it runs; resume
1242+
// still requires the real media completion before delivering events.
1243+
await Future.wait<void>([
1244+
media,
1245+
Future.sync(
1246+
() => controller.evaluateJavascript(source: 'void 0;'),
1247+
).then<void>((_) {}),
1248+
], eagerError: true).timeout(_nativeLifecycleTimeout);
1249+
} else {
1250+
await media.timeout(_nativeLifecycleTimeout);
1251+
}
12371252
} else if (suspended && defaultTargetPlatform == TargetPlatform.android) {
12381253
// onPause אינו עוצר מדיה; כמו ב-Windows, עוזבים טאב — המדיה נעצרת.
12391254
await controller

0 commit comments

Comments
 (0)