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 paint whole layer even only changed partial segment #65007

Closed
fredlee12345678 opened this issue Sep 1, 2020 · 8 comments
Closed

Raster paint whole layer even only changed partial segment #65007

fredlee12345678 opened this issue Sep 1, 2020 · 8 comments
Labels
a: images Loading, displaying, rendering images c: performance Relates to speed or footprint issues (see "perf:" labels) framework flutter/packages/flutter repository. See also f: labels.

Comments

@fredlee12345678
Copy link

Details

Target Platform: Android & IOS
Target OS version/browser:
Devices: All
Flutter Version : 1.17.5

Desctiption

I have a simple code is that :

Code:

body:GridView.builder(
itemCount: 500,
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
mainAxisSpacing: 20.0,
crossAxisSpacing: 10.0,
childAspectRatio: 1.0),
itemBuilder: (context, index) {
return Image.asset('assets/$index');}

If I have an animated image , I found that raster task will paint the whole layer , not the changed layer. I think it's very poor performance. Why not just only paint the changed segment? Thanks

@fredlee12345678 fredlee12345678 added the from: performance template Issues created via a performance issue template label Sep 1, 2020
@pedromassangocode
Copy link

Hi @fredlee12345678
Can you please provide your flutter doctor -v, your flutter run --verbose and a minimal complete reproducible code sample? I need a code that I can just copy/paste to reproduce the issue.

Please also share the actual vs expected results.

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 and removed from: performance template Issues created via a performance issue template labels Sep 1, 2020
@fredlee12345678
Copy link
Author

fredlee12345678 commented Sep 1, 2020

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

void main() {
//  debugPaintLayerBordersEnabled = true;
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
//      checkerboardOffscreenLayers: true,
      checkerboardRasterCacheImages: true,
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
        // This makes the visual density adapt to the platform that you run
        // the app on. For desktop platforms, the controls will be smaller and
        // closer together (more dense) than on mobile platforms.
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: GridView.builder(
          itemCount: 12,
          gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 1,
              mainAxisSpacing: 20.0,
              crossAxisSpacing: 10.0,
              childAspectRatio: 1.0),
          itemBuilder: (context, index) {
            return Image.asset('assets/$index');
          }),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add,color: Colors.red,),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

Here is my asset fils. you can copy it to your project

assets.zip

➜ bin git:(stable) ✗ ./flutter doctor -v
╔════════════════════════════════════════════════════════════════════════════╗
║ A new version of Flutter is available! ║
║ ║
║ To update to the latest version, run "flutter upgrade". ║
╚════════════════════════════════════════════════════════════════════════════╝

[✓] Flutter (Channel stable, v1.17.5, on Mac OS X 10.15.5 19F101, locale zh-Hans-CN)
• Flutter version 1.17.5 at /Users/lixuepeng/Software/flutter1.17.5
• Framework revision 8af6b2f (9 周前), 2020-06-30 12:53:55 -0700
• Engine revision ee76268252
• Dart version 2.8.4

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/lixuepeng/Library/Android/sdk
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = /Users/lixuepeng/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.

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

[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.2)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 39.0.4
• Dart plugin version 192.7761

[✓] Connected device (2 available)
• TRT AL00 • QDY4C17A19002868 • android-arm • Android 7.0 (API 24)
• “lixuepeng”的 iPhone • 00008030-000D71511406802E • ios • iOS 13.5.1

• No issues found!
➜ bin git:(stable) ✗

======================================
The actual:
Flutter will cal 4 picturelayer::paint every frame to redraw the whole screen;

My expect:
Only the first segment is an animated image, I except just call ONE picturelayer::paint every frame just redraw the changed segment

@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 1, 2020
@pedromassangocode
Copy link

Sorry, where this picturelayer::paint is being called? Can you clarify how one can assert that (and where) is picturelayer::paint is being called?
Thank you

@pedromassangocode pedromassangocode added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 1, 2020
@fredlee12345678
Copy link
Author

fredlee12345678 commented Sep 2, 2020

截屏2020-09-02 上午10 40 11

open devtools, can see the PictureLayer::Paint at Raster thread.

@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 2, 2020
@pedromassangocode pedromassangocode added a: images Loading, displaying, rendering images framework flutter/packages/flutter repository. See also f: labels. c: performance Relates to speed or footprint issues (see "perf:" labels) and removed in triage Presently being triaged by the triage team labels Sep 2, 2020
@knopp
Copy link
Member

knopp commented Sep 2, 2020

Possibly duplicate of #33939?

@fredlee12345678
Copy link
Author

@knopp yes, it's same issue, so we can close this issue

@pedromassangocode
Copy link

Closing this one as a duplicate of #33939
Thank you

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: images Loading, displaying, rendering images c: performance Relates to speed or footprint issues (see "perf:" labels) framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

No branches or pull requests

3 participants