Repository: flutter
Issue: [web] Bug in TextPainter. Assertion failed: !debugNeedsLayout
Labels: framework,a: typography,c: rendering,has reproducible steps,P2,found in release: 3.0,found in release: 3.1,team-framework,triaged-framework

<!-- 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 include full steps to reproduce so that we can reproduce the problem. -->



1. Execute `flutter run -d chrome` on the code sample below
2. While the app is loading, move the mouse around in circles over the window.
3. Keep moving the mouse until the Japanese font has loaded, and see the stack trace.
4. If the stack trace doesn't appear, try again (e.g. hot restart, and move the mouse).

**Expected results:** <!-- what did you want to see? -->

No error.

**Actual results:** <!-- what did you see? -->

We see the following error:

```
Error: Assertion failed:
file:///Volumes/Samsung_T5/opt/flutter/packages/flutter/lib/src/painting/text_painter.dart:954:12
!_debugNeedsLayout
is not true
```

Full error in the details below. I have had to truncate the --verbose output since it makes the body too long for a GitHub comment.

<details>
<summary>Code sample</summary>

<!--
      Please create a minimal reproducible sample that shows the problem
      and attach it below between the lines with the backticks.

      To create it you can use `flutter create bug` command and update the `main.dart` file.

      Alternatively, you can use https://dartpad.dev/
      which is capable of creating and running small Flutter apps.

      Without this we will unlikely be able to progress on the issue, and because of that
      we regretfully will have to close it.
-->

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SingleChildScrollView(
          child: RichText(
            text: TextSpan(
              children: [
                for (var i = 0; i < 2000; i++)
                  const TextSpan(
                    text: 'はははは',
                    style: TextStyle(fontSize: 24),
                  ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
```

</details>

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->

```
[ +100 ms] executing: sysctl hw.optional.arm64
[  +18 ms] Exit code 1 from: sysctl hw.optional.arm64
[        ] sysctl: unknown oid 'hw.optional.arm64'
[   +7 ms] executing: [/Volumes/Samsung_T5/opt/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +25 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] ee4e09cce01d6f2d7f4baebd247fde02e5008851
[        ] executing: [/Volumes/Samsung_T5/opt/flutter/] git tag --points-at ee4e09cce01d6f2d7f4baebd247fde02e5008851
[ +155 ms] Exit code 0 from: git tag --points-at ee4e09cce01d6f2d7f4baebd247fde02e5008851
[        ] 3.0.0
[   +9 ms] executing: [/Volumes/Samsung_T5/opt/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +15 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [/Volumes/Samsung_T5/opt/flutter/] git ls-remote --get-url origin
[  +14 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +93 ms] Unable to locate an Android SDK.
[   +4 ms] executing: [/Volumes/Samsung_T5/opt/flutter/] git rev-parse --abbrev-ref HEAD
[  +18 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[   +5 ms] executing: sw_vers -productName
[  +16 ms] Exit code 0 from: sw_vers -productName
[   +1 ms] macOS
[        ] executing: sw_vers -productVersion
[  +14 ms] Exit code 0 from: sw_vers -productVersion
[        ] 11.5.2
[        ] executing: sw_vers -buildVersion
[  +13 ms] Exit code 0 from: sw_vers -buildVersion
[        ] 20G95
[        ] executing: uname -m
[   +5 ms] Exit code 0 from: uname -m
[        ] x86_64
[  +62 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.
[   +4 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'WindowsUwpEngineArtifacts' 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.
[  +57 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.
[   +2 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'WindowsUwpEngineArtifacts' 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.
[  +29 ms] executing: sysctl hw.optional.arm64
[   +4 ms] Exit code 1 from: sysctl hw.optional.arm64
[        ] sysctl: unknown oid 'hw.optional.arm64'
[        ] executing: xcrun xcodebuild -version
[ +544 ms] Exit code 0 from: xcrun xcodebuild -version
[        ] Xcode 12.5.1
           Build version 12E507
[  +64 ms] Skipping pub get: version match.
[ +127 ms] Generating /Volumes/Samsung_T5/projects/text_painter_bug/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[ +184 ms] Launching lib/main.dart on Chrome in debug mode...
[ +130 ms] Updating assets
[  +94 ms] Waiting for connection from debug service on Chrome...
[  +64 ms] <- reset
[  +11 ms] /Volumes/Samsung_T5/opt/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev /Volumes/Samsung_T5/opt/flutter/bin/cache/dart-sdk/bin/snapshots/frontend_server.dart.snapshot --sdk-root /Volumes/Samsung_T5/opt/flutter/bin/cache/flutter_web_sdk/ --incremental --target=dartdevc --debugger-module-names --experimental-emit-debug-metadata -DFLUTTER_WEB_AUTO_DETECT=true --output-dill /var/folders/93/k9f9nls55zxg2jp2hx439wx00000gn/T/flutter_tools.G3uRa9/flutter_tool.1eBqb4/app.dill --libraries-spec file:///Volumes/Samsung_T5/opt/flutter/bin/cache/flutter_web_sdk/libraries.json --packages /Volumes/Samsung_T5/projects/text_painter_bug/.dart_tool/package_config.json -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --filesystem-root /var/folders/93/k9f9nls55zxg2jp2hx439wx00000gn/T/flutter_tools.G3uRa9/flutter_tools.pdgO3j --filesystem-scheme org-dartlang-app --initialize-from-dill build/b1b715402d823b7fd5c2b68d2edcb2ce.cache.dill.track.dill --platform file:///Volumes/Samsung_T5/opt/flutter/bin/cache/flutter_web_sdk/kernel/flutter_ddc_sdk_sound.dill --sound-null-safety
[  +14 ms] <- compile org-dartlang-app:/web_entrypoint.dart
[+17025 ms] Waiting for connection from debug service on Chrome... (completed in 17.1s)
[        ] Synced 29.9MB.
[        ] <- accept
[        ] Caching compiled dill
[ +140 ms] Using Google Chrome 101.0.4951.64 

[   +9 ms] executing: sysctl hw.optional.arm64
[   +6 ms] Exit code 1 from: sysctl hw.optional.arm64
[        ] sysctl: unknown oid 'hw.optional.arm64'
[ +329 ms] [CHROME]: 
[        ] [CHROME]: DevTools listening on ws://127.0.0.1:52771/devtools/browser/2daaaca8-ec6b-4d48-a777-e936ea4a56f4
[+1516 ms] DwdsInjector: Received request for entrypoint at http://localhost:52767/main_module.bootstrap.js
[   +5 ms] MetadataProvider: Loading debug metadata...

---- PORTION DELETED TO FIT IN A GITHUB COMMENT ----

[   +7 ms] DwdsInjector: Injected debugging metadata for entrypoint at http://localhost:52767/main_module.bootstrap.js
[+2883 ms] ChromeProxyService: Initializing expression compiler for main_module.bootstrap.js with sound null safety: true
[  +81 ms] DevHandler: Debug service listening on ws://127.0.0.1:52790/hjzI0AFy3LQ=/ws

[  +23 ms] DevHandler: VmService proxy responded with an error:
           {jsonrpc: 2.0, id: 9, error: {code: -32601, message: Method not found, data: {jsonrpc: 2.0, method: _setStreamIncludePrivateMembers, id: 9, params: {streamId: Stdout, includePrivateMembers: false}}}}
[   +4 ms] This app is linked to the debug service: ws://127.0.0.1:52790/hjzI0AFy3LQ=/ws
[   +1 ms] DevHandler: VmService proxy responded with an error:
           {jsonrpc: 2.0, id: 10, error: {code: -32601, message: Method not found, data: {jsonrpc: 2.0, method: _setStreamIncludePrivateMembers, id: 10, params: {streamId: Stderr, includePrivateMembers: false}}}}
[   +2 ms] DevHandler: VmService proxy responded with an error:
           {jsonrpc: 2.0, id: 11, error: {code: -32601, message: Method not found, data: {jsonrpc: 2.0, method: _setStreamIncludePrivateMembers, id: 11, params: {streamId: Isolate, includePrivateMembers: false}}}}
[   +5 ms] DevHandler: VmService proxy responded with an error:
           {jsonrpc: 2.0, id: 12, error: {code: -32601, message: Method not found, data: {jsonrpc: 2.0, method: _setStreamIncludePrivateMembers, id: 12, params: {streamId: Extension, includePrivateMembers: false}}}}
[   +5 ms] Debug service listening on ws://127.0.0.1:52790/hjzI0AFy3LQ=/ws
[        ] 💪 Running with sound null safety 💪
[   +3 ms] 🔥  To hot restart changes while running, press "r" or "R".
[        ] For a more detailed help message, press "h". To quit, press "q".
[        ] An Observatory debugger and profiler on Chrome is available at: http://127.0.0.1:52790/hjzI0AFy3LQ=
[  +22 ms] Flutter Web Bootstrap: Programmatic
[+1430 ms] The Flutter DevTools debugger and profiler on Chrome is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:52790/hjzI0AFy3LQ=
[+1211 ms] Error: Assertion failed: file:///Volumes/Samsung_T5/opt/flutter/packages/flutter/lib/src/painting/text_painter.dart:954:12
           !_debugNeedsLayout
           is not true
               at Object.throw_ [as throw] (http://localhost:52767/dart_sdk.js:5080:11)
               at Object.assertFailed (http://localhost:52767/dart_sdk.js:5005:15)
               at text_painter.TextPainter.new.getPositionForOffset (http://localhost:52767/packages/flutter/src/painting/placeholder_span.dart.lib.js:2396:43)
               at paragraph.RenderParagraph.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/paragraph.dart.lib.js:611:45)
               at paragraph.RenderParagraph.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at http://localhost:52767/packages/flutter/src/widgets/single_child_scroll_view.dart.lib.js:703:47
               at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:7813:19)
               at single_child_scroll_view._RenderSingleChildViewport.new.hitTestChildren (http://localhost:52767/packages/flutter/src/widgets/single_child_scroll_view.dart.lib.js:701:23)
               at single_child_scroll_view._RenderSingleChildViewport.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderIgnorePointer.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderIgnorePointer.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderIgnorePointer.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:3518:38)
               at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderPointerListener.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderPointerListener.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:538:26)
               at proxy_box.RenderSemanticsGestureHandler.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderSemanticsGestureHandler.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:538:26)
               at proxy_box.RenderPointerListener.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderPointerListener.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:538:26)
               at scrollable$._RenderScrollSemantics.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at scrollable$._RenderScrollSemantics.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderRepaintBoundary.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderRepaintBoundary.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at custom_paint.RenderCustomPaint.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at custom_paint.RenderCustomPaint.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/custom_paint.dart.lib.js:325:20)
               at custom_paint.RenderCustomPaint.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderMouseRegion.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderMouseRegion.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:538:26)
               at proxy_box.RenderMouseRegion.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:3279:20)
               at proxy_box.RenderPointerListener.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderPointerListener.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:538:26)
               at proxy_box.RenderSemanticsGestureHandler.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderSemanticsGestureHandler.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:538:26)
               at proxy_box.RenderRepaintBoundary.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderRepaintBoundary.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:8068:44
               at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:7813:19)
               at custom_layout.RenderCustomMultiChildLayoutBox.new.defaultHitTestChildren (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:8066:30)
               at custom_layout.RenderCustomMultiChildLayoutBox.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/custom_layout.dart.lib.js:283:19)
               at custom_layout.RenderCustomMultiChildLayoutBox.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at material._RenderInkFeatures.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at material._RenderInkFeatures.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderPhysicalModel.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderPhysicalModel.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderPhysicalModel.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:2190:20)
               at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderRepaintBoundary.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderRepaintBoundary.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderIgnorePointer.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderIgnorePointer.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderIgnorePointer.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:3518:38)
               at http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:8068:44
               at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:7813:19)
               at stack.RenderStack.new.defaultHitTestChildren (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:8066:30)
               at stack.RenderStack.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/stack.dart.lib.js:591:19)
               at stack.RenderStack.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderDecoratedBox.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderDecoratedBox.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:3076:244
               at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:7813:19)
               at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:3076:21)
               at proxy_box.RenderFractionalTranslation.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:3071:19)
               at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:3076:244
               at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:7813:19)
               at proxy_box.RenderFractionalTranslation.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:3076:21)
               at proxy_box.RenderFractionalTranslation.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:3071:19)
               at proxy_box.RenderRepaintBoundary.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderRepaintBoundary.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at routes._RenderFocusTrap.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at routes._RenderFocusTrap.new.hitTest (http://localhost:52767/packages/flutter/src/widgets/title.dart.lib.js:16083:26)
               at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderOffstage.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderOffstage.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderOffstage.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:3617:38)
               at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at http://localhost:52767/packages/flutter/src/widgets/title.dart.lib.js:26893:42
               at box.BoxHitTestResult.wrap.addWithPaintOffset (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:7813:19)
               at overlay$._RenderTheatre.new.hitTestChildren (http://localhost:52767/packages/flutter/src/widgets/title.dart.lib.js:26891:28)
               at overlay$._RenderTheatre.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderAbsorbPointer.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderAbsorbPointer.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderAbsorbPointer.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:3691:68)
               at proxy_box.RenderPointerListener.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderPointerListener.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:538:26)
               at custom_paint.RenderCustomPaint.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at custom_paint.RenderCustomPaint.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/custom_paint.dart.lib.js:325:20)
               at custom_paint.RenderCustomPaint.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at proxy_box.RenderSemanticsAnnotations.new.hitTestChildren (http://localhost:52767/packages/flutter/src/rendering/proxy_box.dart.lib.js:438:56)
               at proxy_box.RenderSemanticsAnnotations.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4463:18)
               at view.RenderView.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:4744:58)
               at binding$5.WidgetsFlutterBinding.new.hitTest (http://localhost:52767/packages/flutter/src/rendering/layer.dart.lib.js:5540:23)
               at binding$5.WidgetsFlutterBinding.new.[_handlePointerEventImmediately] (http://localhost:52767/packages/flutter/src/gestures/binding.dart.lib.js:312:14)
               at binding$5.WidgetsFlutterBinding.new.handlePointerEvent (http://localhost:52767/packages/flutter/src/gestures/binding.dart.lib.js:305:43)
               at binding$5.WidgetsFlutterBinding.new.[_flushPointerEventQueue] (http://localhost:52767/packages/flutter/src/gestures/binding.dart.lib.js:295:14)
               at binding$5.WidgetsFlutterBinding.new.[_handlePointerDataPacket] (http://localhost:52767/packages/flutter/src/gestures/binding.dart.lib.js:286:54)
               at Object.invoke1 (http://localhost:52767/dart_sdk.js:191747:7)
               at _engine.EnginePlatformDispatcher.__.invokeOnPointerDataPacket (http://localhost:52767/dart_sdk.js:171943:15)
               at _engine.PointerBinding.__.[_onPointerData] (http://localhost:52767/dart_sdk.js:172879:49)
               at http://localhost:52767/dart_sdk.js:173306:26
               at http://localhost:52767/dart_sdk.js:173273:16
               at loggedHandler (http://localhost:52767/dart_sdk.js:172978:11)

```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
Analyzing text_painter_bug...
No issues found! (ran in 3.5s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 3.0.0, on macOS 11.5.2 20G95 darwin-x64, locale en-AU)
    • Flutter version 3.0.0 at /Volumes/Samsung_T5/opt/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ee4e09cce0 (8 days ago), 2022-05-09 16:45:18 -0700
    • Engine revision d1b9a6938a
    • Dart version 2.17.0
    • DevTools version 2.12.2

[✗] Android toolchain - develop for Android devices
    ✗ ANDROID_HOME = /Users/ryan/opt/android-sdk
      but Android SDK not found at this location.

[!] Xcode - develop for iOS and macOS (Xcode 12.5.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ✗ Flutter requires Xcode 13 or higher.
      Download the latest version or update via the Mac App Store.
    ! CocoaPods 1.10.1 out of date (1.11.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 11.5.2 20G95 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 101.0.4951.64

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 3 categories.
```

</details>


<!--
      Consider also attaching screenshots and/or videos to better
      illustrate the issue.

      You can upload them directly on GitHub.
      Beware that video file size is limited to 10MB.
-->

Notes:

* Related to #98463 but the assertion is triggered by a different widget, so there are multiple causes for this error.
* This might not be web specific as there are also similar non-web reports on StackOverflow [here](https://stackoverflow.com/questions/68457960/needslayout-is-not-true-error-in-flutter-when-changing-between-screens-wi).

By the way, why does Flutter Web not use the source map when printing stack traces in the terminal, but it does inside the JS console? It would be helpful to have the Dart line numbers in the stack trace in both cases.