Repository: flutter
Issue: flutter unit tests (flutter test) with canvaskit renderer do not run (windows)
Labels: a: tests,tool,platform-windows,platform-web,e: web_canvaskit,has reproducible steps,P2,found in release: 3.3,found in release: 3.7,team-web,triaged-web

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Steps to Reproduce

<!-- Please tell us exactly how to reproduce the problem you are running into. -->

1. To the vanilla sample app, add a unit test like the following:
```dart
import 'package:flutter_test/flutter_test.dart';

import 'package:test_with_canvaskit_issue/main.dart';
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' as html;

void main() {
  testWidgets('Detects canvaskit renderer', (WidgetTester tester) async {
    await tester.pumpWidget(const MyApp());
    final rendersWithCanvaskit = html.document.body
            ?.getAttribute("flt-renderer")
            ?.contains("canvaskit") ??
        false;
    expect(rendersWithCanvaskit, true);
  });

  testWidgets('Detects html renderer', (WidgetTester tester) async {
    await tester.pumpWidget(const MyApp());
    final rendersWithHtml=
        html.document.body?.getAttribute("flt-renderer")?.contains("html") ??
            false;
    expect(rendersWithHtml, true);
  });
}

```
2. run `flutter test --platform chrome`: the test results show that by default, the html renderer is used. Great!
3. As expected, the same result when running `flutter test --platform=chrome --web-renderer=html`
4. But running `flutter test --platform=chrome --web-renderer=canvaskit` hangs / completes only on a timeout. See verbose logs below.

I suspect this is a platform issue, occurring at least on Windows, since I do see the canvaskit renderer being targeted in automated flutter tests (see https://github.com/flutter/flutter/blob/f22280a0c851f97be76eedc13a4fd82e8a080f08/dev/bots/test.dart#L255).

Because if this issue, we are forced to cover canvaskit related test cases in integration tests (using `flutter drive`) rather than in unit tests.

## Logs

<details>
<summary>Logs</summary>

<!--
      Include the full logs of the commands you are running between the lines
      with the backticks below. If you are running any "flutter" commands,
      please include the output of running them with "--verbose"; for example,
      the output of running "flutter --verbose create foo".
-->

```
$ flutter test --platform=chrome --web-renderer=canvaskit -v
[  +64 ms] executing: [C:\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +117 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[   +1 ms] 135454af32477f815a7525073027a3ff9eff1bfd
[        ] executing: [C:\flutter/] git tag --points-at 135454af32477f815a7525073027a3ff9eff1bfd
[  +76 ms] Exit code 0 from: git tag --points-at 135454af32477f815a7525073027a3ff9eff1bfd
[        ] 3.3.10
[  +50 ms] executing: [C:\flutter/] git rev-parse --abbrev-ref --symbolic @{upstream}
[  +62 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{upstream}
[        ] origin/stable
[        ] executing: [C:\flutter/] git ls-remote --get-url origin
[  +60 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[ +100 ms] executing: [C:\flutter/] git rev-parse --abbrev-ref HEAD
[  +63 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[  +91 ms] Found 1 files which will be executed as Widget Tests.
[  +10 ms] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +6 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +65 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[   +2 ms] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'PubDependencies' is not required, skipping update.
[  +54 ms] Skipping pub get: version match.
[ +212 ms] Stopping scan for flutter_test_config.dart; found project root at C:\Sources\spikes\test_with_canvaskit_issue
[  +19 ms] C:\flutter\bin\cache\dart-sdk\bin\dart.exe --disable-dart-dev C:\flutter\bin\cache\dart-sdk\bin\snapshots\frontend_server.dart.snapshot --sdk-root
C:\flutter\bin\cache\flutter_web_sdk/ --incremental --target=dartdevc --debugger-module-names --experimental-emit-debug-metadata -DFLUTTER_WEB_AUTO_DETECT=false
-DFLUTTER_WEB_USE_SKIA=true --output-dill C:\Users\ditjy705\AppData\Local\Temp\flutter_tools.1e74917c\flutter_test.f1c13ef5\out --libraries-spec
file:///C:/flutter/bin/cache/flutter_web_sdk/libraries.json --packages C:\Sources\spikes\test_with_canvaskit_issue\.dart_tool\package_config.json -Ddart.vm.profile=false
-Ddart.vm.product=false --enable-asserts --track-widget-creation --filesystem-root C:\Sources\spikes\test_with_canvaskit_issue\test --filesystem-root
C:\Users\ditjy705\AppData\Local\Temp\flutter_tools.1e74917c\flutter_test.f1c13ef5\ --filesystem-scheme org-dartlang-app --initialize-from-dill
build\5ce7c659493310451672e1cde9a7cc60.cache.dill.track.dill --platform file:///C:/flutter/bin/cache/flutter_web_sdk/kernel/flutter_ddc_sdk.dill --verbosity=error --no-sound-null-safety[ +175 ms] <- compile org-dartlang-app:///main.dart
00:00 +0: compiling C:\Sources\spikes\test_with_canvaskit_issue\test\widget_test.dart                                                                                                   [+10197 ms] Serving tests at http://localhost:56944/static/index.html?managerUrl=ws%3A%2F%2Flocalhost%3A56944%2F0&debug=false
[ +213 ms] [CHROME]: 
[   +2 ms] [CHROME]: DevTools listening on ws://127.0.0.1:56946/devtools/browser/e34fb95e-c8a4-4012-bdde-0c2e419872da
06:22 +0: compiling C:\Sources\spikes\test_with_canvaskit_issue\test\widget_test.dart                                                                                                   Terminate batch job (Y/N)? Y
```

<!-- If possible, paste the output of running `flutter doctor -v` here. -->

```
$ flutter doctor -v
[✓] Flutter (Channel stable, 3.3.10, on Microsoft Windows [Version 10.0.19044.2364], locale en-US)
    • Flutter version 3.3.10 on channel stable at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 135454af32 (5 weeks ago), 2022-12-15 07:36:55 -0800
    • Engine revision 3316dd8728
    • Dart version 2.18.6
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) 
    • Android SDK at C:\Users\ditjy705\AppData\Local\Android\sdk
    • Platform android-31, build-tools 30.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java       
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[✓] Visual Studio - develop for Windows (Visual Studio Professional 2019 16.8.2)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
    • Visual Studio Professional 2019 version 16.8.30717.126
    • Windows 10 SDK version 10.0.18362.0

[✓] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[✓] VS Code (version 1.74.3)
    • VS Code at C:\Users\ditjy705\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.56.0

[✓] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19044.2364]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 109.0.5414.74
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 105.0.1343.42

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

```

</details>