-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Closed
Copy link
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listc: regressionIt was better in the past than it is nowIt was better in the past than it is nowe: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for WebCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Webengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13Found to occur in 2.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
I need to use many HtmlElementView widgets but it is not possible because it throws the following error:
WARNING: Too many active WebGL contexts. Oldest context will be lost.
This error happens when I try to run the following command:
flutter run -d chrome --web-renderer canvaskit
It works when I try using html instead of canvaskit. However, I need to optimize the performance instead of the download size.
Here is a minimal example:
// ignore: avoid_web_libraries_in_flutter
import 'dart:html' as html;
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
title: 'Example',
theme: ThemeData(
primarySwatch: Colors.red,
),
home: Scaffold(
appBar: AppBar(
title: Text('HtmlElementView Example'),
),
body: Home(),
),
);
}
}
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
bool _isVisible;
@override
void initState() {
_isVisible = false;
super.initState();
}
@override
Widget build(BuildContext context) {
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 5,
childAspectRatio: MediaQuery.of(context).size.width /
(3 * MediaQuery.of(context).size.height),
),
itemCount: 30,
itemBuilder: (BuildContext context, int index) {
String viewId = 'container_${index + 1}';
html.DivElement htmlData = html.DivElement()
..id = viewId
..text = 'My DivElement ${index + 1}';
// ignore: undefined_prefixed_name
ui.platformViewRegistry
.registerViewFactory(viewId, (int viewId) => htmlData);
return Container(
width: 300,
height: 350,
child: Card(
child: Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Stack(children: <Widget>[
Image.network(
"https://images.unsplash.com/photo-1612923283356-0197f319d603?ixid=MXwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHw0fHx8ZW58MHx8fA%3D%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=500&q=60",
fit: BoxFit.fill,
width: 300,
height: 300,
),
Container(
width: 300,
height: 300,
child: Center(
child: HtmlElementView(viewType: viewId),
),
),
]),
],
),
),
);
});
}
}
If itemCount<16 it works but when itemCount>=16 it doesn't work as expected (I need to have an infinity number of elements in the list)
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.26.0-17.4.pre, on macOS 11.1 20C69 darwin-arm, locale en-AT)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.53.1)
[✓] Connected device (1 available)
• No issues found!
Sammius, creativecreatorormaybenot, radoslaw-sz, samu-developments, esase and 10 more
Metadata
Metadata
Assignees
Labels
P1High-priority issues at the top of the work listHigh-priority issues at the top of the work listc: regressionIt was better in the past than it is nowIt was better in the past than it is nowe: web_canvaskitCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for WebCanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Webengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13Found to occur in 2.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version