Repository: flutter
Issue: Crash in Chrome - Assertion failed: skia_object_cache.dart:248:12 !browserSupportsFinalizationRegistry is not true
Labels: c: crash,engine,platform-web,has reproducible steps,P2,found in release: 2.10,team-web,triaged-web

## Steps to Reproduce

1. Create a new web project by running for instance "flutter create bugrep"

2. Add the following package dependencies in pubspec.yaml:

```
  flutter_form_builder: ^7.0.0
  form_builder_validators: ^7.3.0
  form_builder_extra_fields: ^7.1.0 
```

3. Replace main.dart with below code.

4. Then run the app  in chrome in debug mode. When the application starts, you can select one continent in first typeahead field, then continue to the next field ("percentage") and enter a number like 20, and then try to use backspace or try to edit this value or simply try to exit the field. The application will crash always. 
 

<details>
<summary>Code sample</summary>

```
import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:form_builder_extra_fields/form_builder_extra_fields.dart';
import 'package:form_builder_validators/form_builder_validators.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      debugShowCheckedModeBanner: false,
      localizationsDelegates: const [
        FormBuilderLocalizations.delegate
      ],
      supportedLocales: const [
        Locale('en'), 
      ],
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool refresh = false;
  bool drawingControl = true;


  bool polygonCompleted = false;
  bool enteringNewPolygon = true;
  bool isSaveable = false;

  late double screenWidth;
  late double screenHeight;

  final _formKey = GlobalKey<FormBuilderState>();
  final continents = ['Africa', 'Asia', 'Australia', 'Europe', 'North America', 'South America'];

  // Stepper vars
  int _activeCurrentStep = 0;

  List<Step> stepList() => [
        Step(
          state: _activeCurrentStep <= 1 ? StepState.editing : StepState.complete,
          isActive: _activeCurrentStep >= 1,
          title: const Text('Choose continent'),
          content: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  SizedBox(
                    width: screenWidth * 0.75,
                    child: FormBuilderTypeAhead<String>(
                      validator: FormBuilderValidators.compose(
                        [
                          FormBuilderValidators.required(context),
                        ],
                      ),
                      decoration: const InputDecoration(
                          border: OutlineInputBorder(),
                          labelText: 'TypeAhead (Autocomplete TextField)',
                          hintText: 'Start typing continent name'),
                      name: 'continent',
                      itemBuilder: (context, continent) {
                        return ListTile(title: Text(continent));
                      },
                      suggestionsCallback: (query) {
                        if (query.isNotEmpty) {
                          var lowercaseQuery = query.toLowerCase();
                          return continents.where((continent) {
                            return continent.toLowerCase().contains(lowercaseQuery);
                          }).toList(growable: false)
                            ..sort((a, b) => a
                                .toLowerCase()
                                .indexOf(lowercaseQuery)
                                .compareTo(b.toLowerCase().indexOf(lowercaseQuery)));
                        } else {
                          return continents;
                        }
                      },
                    ),
                  ),
                  SizedBox(
                    width: screenWidth * 0.2,
                    child: FormBuilderTextField(
                      name: 'percentage',
                      decoration: const InputDecoration(
                          border: OutlineInputBorder(),
                          labelText: 'Part %',
                          hintText: 'Enter percentage ..'),
                      validator: FormBuilderValidators.compose(
                        [
                          FormBuilderValidators.required(context),
                        ],
                      ),
                    ),
                  ),
                ],
              ),
            ],
          ),
        ),
        Step(
            state: StepState.complete,
            isActive: _activeCurrentStep >= 5,
            title: const Text('Finalise data entry'),
            content: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              mainAxisAlignment: MainAxisAlignment.start,
              children: const [
                Text('Entered values: .....'),
              ],
            ))
      ];

  _onFormChanged() {
    if (_formKey.currentState != null) {
      _formKey.currentState!.save();
      print('formValid=${_formKey.currentState!.validate()} polyCompleted=$polygonCompleted');
      setState(() {
        isSaveable = _formKey.currentState!.validate();
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    screenWidth = MediaQuery.of(context).size.width;
    screenHeight = MediaQuery.of(context).size.height - 56;
    return Scaffold(
      appBar: AppBar(title: const Text('Bug report reproducible case'),),
      body: SizedBox(
        width: screenWidth,
        child: FormBuilder(
          key: _formKey,
          autovalidateMode: AutovalidateMode.always,
          onChanged: _onFormChanged,
          child: Stepper(
            type: StepperType.horizontal,
            currentStep: _activeCurrentStep,
            steps: stepList(),
            onStepContinue: () {
              if (_activeCurrentStep < (stepList().length - 1)) {
                setState(() {
                  _activeCurrentStep += 1;
                });
              }
            },
            onStepCancel: () {
              if (_activeCurrentStep == 0) {
                return;
              }
              setState(() {
                _activeCurrentStep -= 1;
              });
            },
            onStepTapped: (int index) {
              setState(() {
                _activeCurrentStep = index;
              });
            },
          ),
        ),
      ),
    );
  }
}
```


</details>

<details>
  <summary>Logs</summary>



```
═╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
Assertion failed:
[org-dartlang-sdk:///flutter_web_sdk/lib/_engine/engine/canvaskit/skia_object_cache.dart:248:12]()
!browserSupportsFinalizationRegistry
is not true
When the exception was thrown, this was the stack:
dart-sdk[/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart]() 251:49  throw_
dart-sdk[/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart]() 29:3    assertFailed
lib[/_engine/engine/canvaskit/skia_object_cache.dart]() 248:13                    [_doResurrect]
lib[/_engine/engine/canvaskit/skia_object_cache.dart]() 245:40                    get skiaObject
lib[/_engine/engine/canvaskit/canvas.dart]() 210:33                               drawPicture
lib[/_engine/engine/canvaskit/layer.dart]() 467:17                                paint
lib[/_engine/engine/canvaskit/layer.dart]() 141:14                                paintChildren
lib[/_engine/engine/canvaskit/layer.dart]() 368:5                                 paint
lib[/_engine/engine/canvaskit/layer.dart]() 141:14                                paintChildren
lib[/_engine/engine/canvaskit/layer.dart]() 368:5                                 paint
lib[/_engine/engine/canvaskit/layer.dart]() 141:14                                paintChildren
lib[/_engine/engine/canvaskit/layer.dart]() 368:5                                 paint
lib[/_engine/engine/canvaskit/layer.dart]() 141:14                                paintChildren
lib[/_engine/engine/canvaskit/layer.dart]() 368:5                                 paint
lib[/_engine/engine/canvaskit/layer.dart]() 141:14                                paintChildren
lib[/_engine/engine/canvaskit/layer.dart]() 368:5                                 paint
lib[/_engine/engine/canvaskit/layer.dart]() 141:14                                paintChildren
lib[/_engine/engine/canvaskit/layer.dart]() 537:5                                 paint
lib[/_engine/engine/canvaskit/layer.dart]() 141:14                                paintChildren
lib[/_engine/engine/canvaskit/layer.dart]() 368:5                                 paint
lib[/_engine/engine/canvaskit/layer.dart]() 141:14                                paintChildren
lib[/_engine/engine/canvaskit/layer.dart]() 368:5                                 paint
lib[/_engine/engine/canvaskit/layer.dart]() 141:14                                paintChildren
lib[/_engine/engine/canvaskit/layer.dart]() 368:5                                 paint
lib[/_engine/engine/canvaskit/layer.dart]() 141:14                                paintChildren
lib[/_engine/engine/canvaskit/layer.dart]() 154:5                                 paint
lib[/_engine/engine/canvaskit/layer_tree.dart]() 56:17                            paint
lib[/_engine/engine/canvaskit/layer_tree.dart]() 99:16                            <fn>
lib[/_engine/engine/profiler.dart]() 34:18                                        timeAction
lib[/_engine/engine/canvaskit/layer_tree.dart]() 98:5                             raster
lib[/_engine/engine/canvaskit/rasterizer.dart]() 33:22                            draw
lib[/_engine/engine/platform_dispatcher.dart]() 585:7                             render
lib[/ui/src/ui/window.dart]() 94:50                                               render
packages[/flutter/src/rendering/view.dart]() 231:15                               compositeFrame
packages[/flutter/src/rendering/binding.dart]() 501:18                            drawFrame
packages[/flutter/src/widgets/binding.dart]() 883:13                              drawFrame
packages[/flutter/src/rendering/binding.dart]() 363:5                             [_handlePersistentFrameCallback]
packages[/flutter/src/scheduler/binding.dart]() 1144:15                           [_invokeFrameCallback]
packages[/flutter/src/scheduler/binding.dart]() 1081:9                            handleDrawFrame
packages[/flutter/src/scheduler/binding.dart]() 995:5                             [_handleDrawFrame]
lib[/_engine/engine/platform_dispatcher.dart]() 1011:13                           invoke
lib[/_engine/engine/platform_dispatcher.dart]() 159:5                             invokeOnDrawFrame
lib[/_engine/engine/initialization.dart]() 128:45                                 <fn>
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: Assertion failed: [org-dartlang-sdk:///flutter_web_sdk/lib/_engine/engine/canvaskit/skia_object_cache.dart:248:12]()
```

With HTML renderer the crash report is different:
```
flutter run -d chrome --web-renderer html
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...             24.5s
This app is linked to the debug service: ws://127.0.0.1:60636/N9PlJiV0qCc=/ws
Debug service listening on ws://127.0.0.1:60636/N9PlJiV0qCc=/ws

💪 Running with sound null safety 💪

🔥  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:60636/N9PlJiV0qCc=
The Flutter DevTools debugger and profiler on Chrome is available at:
http://127.0.0.1:9103?uri=http://127.0.0.1:60636/N9PlJiV0qCc=
formValid=false polyCompleted=false
formValid=false polyCompleted=false
formValid=true polyCompleted=false
formValid=true polyCompleted=false
══╡ EXCEPTION CAUGHT BY SCHEDULER LIBRARY ╞═════════════════════════════════════════════════════════
The following PersistedSurfaceException was thrown during a scheduler callback:
PersistedOffset: is in an unexpected state.
Expected one of: PersistedSurfaceState.released
But was: PersistedSurfaceState.active

When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 251:49  throw_
lib/_engine/engine/html/surface.dart 180:3                                    debugAssertSurfaceState
lib/_engine/engine/html/surface.dart 284:12                                   revive
lib/_engine/engine/html/surface.dart 1147:11                                  revive
lib/_engine/engine/html/surface.dart 1150:18                                  revive
lib/_engine/engine/html/surface.dart 272:7                                    tryRetain
lib/_engine/engine/html/scene_builder.dart 297:20                             addRetained
packages/flutter/src/rendering/layer.dart 542:14                              [_addToSceneWithRetainedRendering]
packages/flutter/src/rendering/layer.dart 1105:12                             addChildrenToScene
packages/flutter/src/rendering/layer.dart 1239:5                              addToScene
packages/flutter/src/rendering/layer.dart 545:5                               [_addToSceneWithRetainedRendering]
packages/flutter/src/rendering/layer.dart 1105:12                             addChildrenToScene
packages/flutter/src/rendering/layer.dart 1239:5                              addToScene
packages/flutter/src/rendering/layer.dart 545:5                               [_addToSceneWithRetainedRendering]
packages/flutter/src/rendering/layer.dart 1105:12                             addChildrenToScene
packages/flutter/src/rendering/layer.dart 1239:5                              addToScene
packages/flutter/src/rendering/layer.dart 545:5                               [_addToSceneWithRetainedRendering]
packages/flutter/src/rendering/layer.dart 1105:12                             addChildrenToScene
packages/flutter/src/rendering/layer.dart 1239:5                              addToScene
packages/flutter/src/rendering/layer.dart 545:5                               [_addToSceneWithRetainedRendering]
packages/flutter/src/rendering/layer.dart 1105:12                             addChildrenToScene
packages/flutter/src/rendering/layer.dart 2085:5                              addToScene
packages/flutter/src/rendering/layer.dart 545:5                               [_addToSceneWithRetainedRendering]
packages/flutter/src/rendering/layer.dart 1105:12                             addChildrenToScene
packages/flutter/src/rendering/layer.dart 1239:5                              addToScene
packages/flutter/src/rendering/layer.dart 545:5                               [_addToSceneWithRetainedRendering]
packages/flutter/src/rendering/layer.dart 1105:12                             addChildrenToScene
packages/flutter/src/rendering/layer.dart 1239:5                              addToScene
packages/flutter/src/rendering/layer.dart 545:5                               [_addToSceneWithRetainedRendering]
packages/flutter/src/rendering/layer.dart 1105:12                             addChildrenToScene
packages/flutter/src/rendering/layer.dart 1680:5                              addToScene
packages/flutter/src/rendering/layer.dart 937:5                               buildScene
packages/flutter/src/rendering/view.dart 228:30                               compositeFrame
packages/flutter/src/rendering/binding.dart 501:18                            drawFrame
packages/flutter/src/widgets/binding.dart 883:13                              drawFrame
packages/flutter/src/rendering/binding.dart 363:5                             [_handlePersistentFrameCallback]
packages/flutter/src/scheduler/binding.dart 1144:15                           [_invokeFrameCallback]
packages/flutter/src/scheduler/binding.dart 1081:9                            handleDrawFrame
packages/flutter/src/scheduler/binding.dart 995:5                             [_handleDrawFrame]
lib/_engine/engine/platform_dispatcher.dart 1011:13                           invoke
lib/_engine/engine/platform_dispatcher.dart 159:5                             invokeOnDrawFrame
lib/_engine/engine/initialization.dart 128:45                                 <fn>
════════════════════════════════════════════════════════════════════════════════════════════════════ 
```
<!--
     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 bugrep...                                                     

   info • Avoid `print` calls in production code • lib/main.dart:138:7 • avoid_print

1 issue found. (ran in 2.2s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

[✓] Flutter (Channel stable, 2.10.5, on Mac OS X 10.15.7 19H1217 darwin-x64, locale en-SI)
    • Flutter version 2.10.5 at /Users/xxxxx/development/flutter_2.8
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5464c5bac7 (2 days ago), 2022-04-18 09:55:37 -0700
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/xxxxx/Library/Android/sdk
    • Platform android-31, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 12.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.66.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.38.1

[✓] VS Code (version 1.54.1)
    • VS Code at /Users/xxxxx/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.38.1

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 100.0.4896.127

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

</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.
-->