Repository: flutter
Issue: Flutter test is stuck on splash screen when using `LiveTestWidgetsFlutterBindingFramePolicy.benchmark`
Labels: framework,f: integration_test,has reproducible steps,P3,team-framework,triaged-framework,found in release: 3.19,found in release: 3.20

### Steps to reproduce

1. Create example Flutter app (counter)
2. Run
```console
flutter build apk \
    --profile \
    --target=benchmark/counter_benchmark_test.dart
    
flutter drive \
    --driver=benchmark/performance_driver.dart \
    --target=benchmark/counter_benchmark_test.dart \
    --no-dds \
    --endless-trace-buffer \
    --purge-persistent-cache \
    --use-application-binary=build/app/outputs/flutter-apk/app-profile.apk
```

### Expected results

Test is run as expected.

### Actual results

Test is stuck on the splash screen.

### Code sample

<details open><summary>benchmark/counter_benchmark_test.dart</summary>

```dart
import 'package:flutter_benchmark/main.dart' as app;
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

void main() {
  final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.benchmark;

  group(
    '',
    () {
      testWidgets(
        'Build',
        (tester) async {
          await tester.pumpWidget(const app.MyApp());
          await tester.pumpAndSettle();
        },
        tags: ["Performance"],
      );
    },
  );
}

```

</details>

<details open><summary>benchmark/performance_driver.dart</summary>

```dart
import 'dart:developer';

import 'package:flutter_driver/flutter_driver.dart' as driver;
import 'package:integration_test/integration_test_driver.dart';

Future<void> main() async {
  await integrationDriver(
    responseDataCallback: (data) async {
      if (data != null) {
        for (final String timelineName in data.keys) {
          final timeline = driver.Timeline.fromJson(data[timelineName] as Map<String, dynamic>);
          final summary = driver.TimelineSummary.summarize(timeline);

          try {
            // Write the entire timeline and summary to disk in a json format.
            // This file can be opened in the Chrome browser's tracing tools
            // found by navigating to chrome://tracing.
            await summary.writeTimelineToFile(
              timelineName,
              pretty: true,
            );
          } catch (e) {
            log(e.toString());
          }
        }
      }
    },
  );
}

```

</details>

### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details open><summary>Logs</summary>

```console
Installing build/app/outputs/flutter-apk/app-profile.apk...      2,054ms
I/SurfaceView@c2f5d60( 5549): onWindowVisibilityChanged(0) true io.flutter.embedding.android.FlutterSurfaceView{c2f5d60 V.E...... ......I.
0,0-0,0} of ViewRootImpl@a5fa424[MainActivity]
D/SurfaceView@c2f5d60( 5549): updateSurface: has no frame
I/ViewRootImpl@a5fa424[MainActivity]( 5549): performTraversals params={(0,0)(fillxfill) sim={adjust=resize forwardNavigation} ty=BASE_APPLICATION
wanim=0x1030001
I/ViewRootImpl@a5fa424[MainActivity]( 5549):   fl=81810100
I/ViewRootImpl@a5fa424[MainActivity]( 5549):   pfl=12020040
I/ViewRootImpl@a5fa424[MainActivity]( 5549):   vsysui=500
I/ViewRootImpl@a5fa424[MainActivity]( 5549):   bhv=DEFAULT
I/ViewRootImpl@a5fa424[MainActivity]( 5549):   fitSides= naviIconColor=0
I/ViewRootImpl@a5fa424[MainActivity]( 5549):   sfl=100000}
I/ViewRootImpl@a5fa424[MainActivity]( 5549): performTraversals mFirst=true windowShouldResize=true viewVisibilityChanged=false
mForceNextWindowRelayout=false params={(0,0)(fillxfill) sim={adjust=resize forwardNavigation} ty=BASE_APPLICATION fmt=TRANSLUCENT wanim=0x1030001
I/ViewRootImpl@a5fa424[MainActivity]( 5549):   fl=81810100
I/ViewRootImpl@a5fa424[MainActivity]( 5549):   pfl=12020040
I/ViewRootImpl@a5fa424[MainActivity]( 5549):   vsysui=500
I/ViewRootImpl@a5fa424[MainActivity]( 5549):   bhv=DEFAULT
I/ViewRootImpl@a5fa424[MainActivity]( 5549):   fitSides= naviIconColor=0
I/ViewRootImpl@a5fa424[MainActivity]( 5549):   sfl=100000}
I/ViewRootImpl@a5fa424[MainActivity]( 5549): updateBlastSurfaceIfNeeded mBlastBufferQueue=null isSameSurfaceControl=false
I/BLASTBufferQueue( 5549): new BLASTBufferQueue, mName= ViewRootImpl@a5fa424[MainActivity] mNativeObject= 0x77cb534ab0 sc.mNativeObject=
0x775b531100 caller= android.view.ViewRootImpl.updateBlastSurfaceIfNeeded:2909 android.view.ViewRootImpl.relayoutWindow:9847
android.view.ViewRootImpl.performTraversals:3884 android.view.ViewRootImpl.doTraversal:3116 android.view.ViewRootImpl$TraversalRunnable.run:10885
android.view.Choreographer$CallbackRecord.run:1301 android.view.Choreographer$CallbackRecord.run:1309 android.view.Choreographer.doCallbacks:923
android.view.Choreographer.doFrame:852 android.view.Choreographer$FrameDisplayEventReceiver.run:1283
I/BLASTBufferQueue( 5549): update, w= 1080 h= 2400 mName = ViewRootImpl@a5fa424[MainActivity] mNativeObject= 0x77cb534ab0 sc.mNativeObject=
0x775b531100 format= -3 caller= android.graphics.BLASTBufferQueue.<init>:84 android.view.ViewRootImpl.updateBlastSurfaceIfNeeded:2909
android.view.ViewRootImpl.relayoutWindow:9847 android.view.ViewRootImpl.performTraversals:3884 android.view.ViewRootImpl.doTraversal:3116
android.view.ViewRootImpl$TraversalRunnable.run:10885
I/ViewRootImpl@a5fa424[MainActivity]( 5549): Relayout returned: old=(0,0,1080,2400) new=(0,0,1080,2400) req=(1080,2400)0 dur=6 res=0x3 s={true
0x785b58dff0} ch=true seqId=0
I/ViewRootImpl@a5fa424[MainActivity]( 5549): mThreadedRenderer.initialize() mSurface={isValid=true 0x785b58dff0} hwInitialized=true
D/SurfaceView@c2f5d60( 5549): updateSurface: has no frame
I/SurfaceView@c2f5d60( 5549): windowStopped(false) true io.flutter.embedding.android.FlutterSurfaceView{c2f5d60 V.E...... ......ID 0,0-1080,2361}
of ViewRootImpl@a5fa424[MainActivity]
D/SurfaceView@c2f5d60( 5549): updateSurface: has no frame
I/ViewRootImpl@a5fa424[MainActivity]( 5549): reportNextDraw android.view.ViewRootImpl.performTraversals:4438
android.view.ViewRootImpl.doTraversal:3116 android.view.ViewRootImpl$TraversalRunnable.run:10885
android.view.Choreographer$CallbackRecord.run:1301 android.view.Choreographer$CallbackRecord.run:1309
I/SurfaceView@c2f5d60( 5549): Changes: creating=true format=true size=true visible=true alpha=false hint=false mUseAlpha=false visible=true
left=true top=true
D/OpenGLRenderer( 5549): eglCreateWindowSurface
I/BLASTBufferQueue( 5549): update, w= 1080 h= 2361 mName = null mNativeObject= 0x77cb52da30 sc.mNativeObject= 0x775b530e40 format= 4 caller=
android.view.SurfaceView.createBlastSurfaceControls:1383 android.view.SurfaceView.updateSurface:1079
android.view.SurfaceView.lambda$new$0$android-view-SurfaceView:200 android.view.SurfaceView$$ExternalSyntheticLambda5.onPreDraw:2
android.view.ViewTreeObserver.dispatchOnPreDraw:1121 android.view.ViewRootImpl.performTraversals:4442
I/SurfaceView@c2f5d60( 5549): 204430688 Cur surface: Surface(name=null)/@0xfe2e4f0
I/SurfaceView@c2f5d60( 5549): pST: sr = Rect(0, 0 - 1080, 2361) sw = 1080 sh = 2361
D/SurfaceView@c2f5d60( 5549): performSurfaceTransaction RenderWorker position = [0, 0, 1080, 2361] surfaceSize = 1080x2361
I/SurfaceView@c2f5d60( 5549): applyTransactionOnVriDraw: vri = ViewRootImpl@a5fa424[MainActivity] fRS = false t = 0x778b541530
android.view.SurfaceView.performSurfaceTransaction:959 android.view.SurfaceView.updateSurface:1105
android.view.SurfaceView.lambda$new$0$android-view-SurfaceView:200
I/ViewRootImpl@a5fa424[MainActivity]( 5549): applyTransactionOnDraw: mRemoved = false isHardwareEnabled = true t =
0x778b541530android.view.SurfaceView.applyTransactionOnVriDraw:2048 android.view.SurfaceView.performSurfaceTransaction:959
android.view.SurfaceView.updateSurface:1105 android.view.SurfaceView.lambda$new$0$android-view-SurfaceView:200
android.view.SurfaceView$$ExternalSyntheticLambda5.onPreDraw:2
I/SurfaceView@c2f5d60( 5549): updateSurface: mVisible = true mSurface.isValid() = true
I/SurfaceView@c2f5d60( 5549): updateSurface: mSurfaceCreated = false surfaceChanged = true visibleChanged = true
I/SurfaceView@c2f5d60( 5549): visibleChanged -- surfaceCreated
I/SurfaceView@c2f5d60( 5549): surfaceCreated 1 #8 io.flutter.embedding.android.FlutterSurfaceView{c2f5d60 V.E...... ......ID 0,0-1080,2361}
I/SurfaceView@c2f5d60( 5549): surfaceChanged -- format=4 w=1080 h=2361
I/SurfaceView@c2f5d60( 5549): surfaceChanged (1080,2361) 1 #8 io.flutter.embedding.android.FlutterSurfaceView{c2f5d60 V.E...... ......ID
0,0-1080,2361}
I/SurfaceView@c2f5d60( 5549): surfaceRedrawNeeded
V/SurfaceView@c2f5d60( 5549): Layout: x=0 y=0 w=1080 h=2361, frame=Rect(0, 0 - 1080, 2361)
I/SurfaceView@c2f5d60( 5549): finishedDrawing
VMServiceFlutterDriver: Connecting to Flutter application at http://127.0.0.1:56249/2BKW0OWrTXY=/
VMServiceFlutterDriver: Isolate found with number: 7756209112850867
VMServiceFlutterDriver: Isolate is paused at start.
VMServiceFlutterDriver: Attempting to resume isolate
I/flutter ( 5549): 00:00 +0: Warmup Build (day)
VMServiceFlutterDriver: Connected to Flutter application.

```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.1, on macOS 14.0 23A344 darwin-arm64, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.86.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!
```

</details>