Skip to content

[web] svgClip "leak" in canvaskit renderer #82768

Description

@ditman

Steps to Reproduce

  1. Run the following app in canvaskit mode:
main.dart
import 'dart:html' as html;
import 'dart:ui' as ui;

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      home: _App(),
    ),
  );
}

class _App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body:
            _RotatingClipRRect(),
      );
  }
}

class _RotatingClipRRect extends StatefulWidget {
  @override
  _RotatingClipRRectState createState() => _RotatingClipRRectState();
}

class _RotatingClipRRectState extends State<_RotatingClipRRect> with TickerProviderStateMixin {
  late AnimationController _animationController;
  late Animation<double> _animation;

  @override
  void initState() {
    super.initState();
    _animationController = AnimationController(
      vsync: this,
      duration: const Duration(milliseconds: 5000),
      value: 0,
      lowerBound: 0,
      upperBound: 1,
    )..repeat();

    _animation = CurvedAnimation(
      parent: _animationController,
      curve: Curves.linear,
    );

    ui.platformViewRegistry.registerViewFactory(
      'test', (_) => html.DivElement()..style.background = '#fabada'
    );
  }

  @override
  Widget build(BuildContext context) {
    return Center(
        child: Container(
          child: RotationTransition(
            turns: _animation,
            child: SizedBox(
              width: 320,
              height: 200,
              child: ClipRRect(
                borderRadius: BorderRadius.circular(10.0),
                child: HtmlElementView(viewType: 'test',),
              ),
            ),
          ),
        ),
      );
  }

  @override
  void dispose() {
    _animationController.dispose();
    super.dispose();
  }
}
  1. In DevTools, locate the flt-clip tag that is being updated a lot. Close to it, there will be an svg tag with defs that gets a new element on every frame:
Screen.Recording.2021-05-17.at.4.48.22.PM.mov

Expected results: I'd expect the svg defs to stay contained (maybe not recreated?)

Actual results: A new svg def is being created per frame, and it never stops, until the browser starts to give up. This looks like a leak.

Logs
$ flutter doctor -v
[✓] Flutter (Channel master, 2.3.0-2.0.pre.42, on Linux, locale en_US.UTF-8)
    • Flutter version 2.3.0-2.0.pre.42 at /usr/local/google/home/dit/github/flutter
    • Upstream repository git@github.com:ditman/flutter.git
    • Framework revision 7f1d1414cc (13 days ago), 2021-05-04 06:17:19 -0700
    • Engine revision 378e4dbc41
    • Dart version 2.14.0 (build 2.14.0-48.0.dev)

Metadata

Metadata

Labels

P1High-priority issues at the top of the work liste: 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
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions