Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raster cache images may be much bigger than the visible/clipped area #25155

Closed
d0bry opened this issue Dec 10, 2018 · 4 comments
Closed

Raster cache images may be much bigger than the visible/clipped area #25155

d0bry opened this issue Dec 10, 2018 · 4 comments
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) engine flutter/engine repository. See also e: labels. found in release: 1.20 Found to occur in 1.20 framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list perf: memory Performance issues related to memory team-engine Owned by Engine team triaged-engine Triaged by Engine team

Comments

@d0bry
Copy link

d0bry commented Dec 10, 2018

The size of raster cache image is based only on drawing operations and may be unnecessarily big. This is particularly important for custom widgets with pinch-to-zoom functionality, where after zooming the painted area may be much bigger than the viewport. In my case it caused crashes (GPU memory issues?) on some devices. The only way to work around is to use willChange hint to disable caching for such widget (even though it would benefit from caching).

I've found no way to limit the size to the clipped area.

Also, if this causes random issues, it is really hard to find the cause without using checkerboardRasterCacheImages.

Example:

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(),
      checkerboardRasterCacheImages: true,
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: RepaintBoundary(
          child: Container(
            width: 100.0,
            height: 100.0,
            child: CustomPaint(
              painter: TestImagePainter(),
            ),
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => setState(() {}),
        child: Icon(Icons.add),
      ),
    );
  }
}

class TestImagePainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    canvas.clipRect(Offset.zero & size);
    for (int i = 0; i < 300; i++) {
      canvas.drawRect(Offset(10.0 * i, 10.0 * i) & Size(10.0, 10.0),
          Paint()..color = Colors.red);
    }
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) => true;
}

screenshot_1544437474

@d0bry
Copy link
Author

d0bry commented Dec 10, 2018

[√] Flutter (Channel beta, v1.0.0, on Microsoft Windows [Version 10.0.17134.407],
    locale pl-PL)
[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[√] Android Studio (version 3.2)
[√] Connected device (2 available)

@zoechi zoechi added framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine repository. See also e: labels. dependency: skia Skia team may need to help us labels Dec 10, 2018
@zoechi zoechi added this to the Goals milestone Dec 10, 2018
@goderbauer goderbauer added the c: performance Relates to speed or footprint issues (see "perf:" labels) label Jan 4, 2019
@chinmaygarde chinmaygarde removed the dependency: skia Skia team may need to help us label Jan 28, 2019
@dnfield dnfield added the perf: memory Performance issues related to memory label May 18, 2020
@kf6gpe kf6gpe added the P2 Important issues not at the top of the work list label May 29, 2020
@Hixie Hixie removed this from the None. milestone Aug 17, 2020
@pedromassangocode
Copy link

Hi @d0bry
Are you still facing this issue? If yes, please provide your flutter doctor -v, your flutter run --verbose?
Thank you

@pedromassangocode pedromassangocode added in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Sep 16, 2020
@d0bry
Copy link
Author

d0bry commented Sep 21, 2020

I forgot about this issue, but I just checked with the sample code above and it still exists in Flutter version 1.20.4.
Yet if no one else has complained in almost two years, then it's probably not that significant.

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 21, 2020
@pedromassangocode pedromassangocode removed the in triage Presently being triaged by the triage team label Sep 22, 2020
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-engine Owned by Engine team triaged-engine Triaged by Engine team labels Jul 7, 2023
@Hixie
Copy link
Contributor

Hixie commented May 2, 2024

The raster cache is a legacy feature at this point (no plans on adding it to impeller) so I'm going to close this.

@Hixie Hixie closed this as completed May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) engine flutter/engine repository. See also e: labels. found in release: 1.20 Found to occur in 1.20 framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list perf: memory Performance issues related to memory team-engine Owned by Engine team triaged-engine Triaged by Engine team
Projects
None yet
Development

No branches or pull requests

9 participants