Skip to content

[Impeller]: resources exhausted when animating mask blur points #152780

@Hixie

Description

@Hixie

I ran the following code on my Pixel 6A running Android 13 and the entire phone rebooted:

import 'dart:async';
import 'dart:ui';

import 'package:flutter/material.dart';

void main() {
  runApp(const Test());
}

class Test extends StatefulWidget {
  const Test({super.key});

  @override
  State<Test> createState() => _TestState();
}

class _TestState extends State<Test> {
  Timer? _timer;
  double _x = 1.0;
  
  @override
  void initState() {
    super.initState();
    _timer = Timer.periodic(const Duration(milliseconds: 100), _update);
  }

  void _update(Timer timer) {
    setState(() {
      _x *= 10;
      if (_x > 1e20) {
        _x = 1e-20;
      }
    });
  }
  
  @override
  void dispose() {
    _timer?.cancel();
    super.dispose();
  }
  
  @override
  Widget build(BuildContext context) {
    return Stack(
      textDirection: TextDirection.ltr,
      children: [
        CustomPaint(
          painter: Painter(_x),
        ),
        Positioned(
          top: 60.0,
          left: 20.0,
          child: Text(_x.toStringAsExponential(1), textDirection: TextDirection.ltr),
        ),
      ],
    );
  }
}

class Painter extends CustomPainter {
  Painter(this.x);

  final double x;
  
  @override
  void paint(Canvas canvas, Size size) {
    canvas.scale(1.0 / x);
    final Paint paint = Paint()
      ..strokeWidth = 50.0 * x
      ..strokeCap = StrokeCap.round
      ..color = const Color(0xFF66BBFF);
    canvas.drawPoints(PointMode.points, <Offset>[ Offset(200.0 * x, 200.0 * x) ], paint);

    paint.maskFilter = MaskFilter.blur(BlurStyle.normal, 10.0 * x);
    canvas.drawPoints(PointMode.points, <Offset>[ Offset(200.0 * x, 400.0 * x) ], paint);
  }

  @override
  bool shouldRepaint(Painter oldDelegate) => false;
}

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work liste: impellerImpeller rendering backend issues and features requeststeam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions