Skip to content

[Web] [CanvasKit] Too many active WebGL contexts #50719

@cbenhagen

Description

@cbenhagen

Creating many HtmlElementView is not currently possible because it will throw the following error:
Too many active WebGL contexts. Oldest context will be lost.

import 'dart:html';
import 'dart:ui' as ui;

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    ui.platformViewRegistry
        .registerViewFactory('xyz', (int viewId) => SpanElement());
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: GridView.count(
        crossAxisCount: 3,
        children: List.generate(
          20,
          (i) => Container(
            color: i.isEven ? Colors.blue : Colors.white,
            child: HtmlElementView(
              viewType: 'xyz',
            ),
          ),
        ),
      ),
    );
  }
}
[✓] Flutter (Channel master, v1.15.4-pre.51, on Mac OS X 10.15.3 19D76, locale en-CH)
    • Flutter version 1.15.4-pre.51 at /Users/ben/flutter
    • Framework revision dc636069fc (6 hours ago), 2020-02-12 22:22:49 -0800
    • Engine revision e0ebaea590
    • Dart version 2.8.0 (build 2.8.0-dev.9.0 e4c39721c4)


[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/ben/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C504
    • CocoaPods version 1.8.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 43.0.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.41.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.7.1

[✓] Connected device (3 available)
    • macOS      • macOS      • darwin-x64     • Mac OS X 10.15.3 19D76
    • Chrome     • chrome     • web-javascript • Google Chrome 80.0.3987.100
    • Web Server • web-server • web-javascript • Flutter Tools

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listdependency: skiaSkia team may need to help use: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Webengineflutter/engine related. See also e: labels.platform-webWeb applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions