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

Cannot reduce graphics memory leak of my android app #26837

Closed
yashwanthBhargav opened this issue Jan 21, 2019 · 13 comments
Closed

Cannot reduce graphics memory leak of my android app #26837

yashwanthBhargav opened this issue Jan 21, 2019 · 13 comments
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) dependency: skia Skia team may need to help us engine flutter/engine repository. See also e: labels. framework flutter/packages/flutter repository. See also f: labels.

Comments

@yashwanthBhargav
Copy link

yashwanthBhargav commented Jan 21, 2019

capture
capture2

I am using ImageProvider in 2 parts of my code
1.getting bytes from a file in system
2. drawing image on canvas
And i guess this is the reason for the memory leak
I tried clearing the imageCache of the PaintingBinding but didnot solve my problem

@yashwanthBhargav yashwanthBhargav changed the title Cannot reduce graphics memory leak of my app Cannot reduce graphics memory leak of my android app Jan 21, 2019
@zoechi
Copy link
Contributor

zoechi commented Jan 21, 2019

Please add the output of flutter doctor -v.

To investigate we would need a minimal runnable reproduction
as a single file so that we can just copy your code into lib/main.dart of a new project and run to reproduce.

@zoechi zoechi added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 21, 2019
@yashwanthBhargav
Copy link
Author

yashwanthBhargav commented Jan 21, 2019

Output of flutter doctor

[√] Flutter (Channel beta, v1.0.0, on Microsoft Windows [Version 10.0.17134.523], locale en-US)
    • Flutter version 1.0.0 at C:\Users\USER\Desktop\flutter
    • Framework revision 5391447fae (7 weeks ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at C:\Users\USER\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[√] Android Studio (version 3.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 31.3.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[√] VS Code, 64-bit edition (version 1.30.2)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 2.21.1

• No issues found!

@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 Jan 21, 2019
@zoechi zoechi added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 21, 2019
@yashwanthBhargav
Copy link
Author

yashwanthBhargav commented Jan 21, 2019

@zoechi Thank you for replying.

It's in general with any canvas, here run this app :
DrawApp Reproduction

Steps :

  • Run any flutter canvas app
  • Run the Profiler in android studio
  • Check for graphics memory
  • Doodle a lot on the canvas using 2 finger touch gesture, I mean a lot please
  • Graphic memory will be like 1GB or more
  • Clear canvas and wait
  • Memory won't come down, won't free memory (Manual System GC on native java using method channel won't work either)

I am trying to make the same app like that one.

@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 Jan 21, 2019
@zoechi zoechi added engine flutter/engine repository. See also e: labels. c: performance Relates to speed or footprint issues (see "perf:" labels) labels Jan 21, 2019
@zoechi zoechi added this to the Goals milestone Jan 21, 2019
@zoechi zoechi added the framework flutter/packages/flutter repository. See also f: labels. label Jan 21, 2019
@yashwanthBhargav
Copy link
Author

@zoechi It would help us if we have a work around or something to clear graphics memory, cuz we will be using our application in production. Right now it takes around 0.7-1GB which isn't good for our app.

@zoechi
Copy link
Contributor

zoechi commented Jan 21, 2019

Have you also tried if you can still reproduce with master or dev channel?

@yashwanthBhargav
Copy link
Author

yashwanthBhargav commented Jan 21, 2019

Isn't latest stable is on Master? I haven't tried with dev channel

EDIT: I am on beta

@zoechi
Copy link
Contributor

zoechi commented Jan 21, 2019

Latest stable is from about December 1st and master is from yesterday and dev is usually about 1-5 days old. beta is also from

(7 weeks ago), 2018-11-29 19:41:26 -0800

@yashwanthBhargav
Copy link
Author

yashwanthBhargav commented Jan 21, 2019

All numbers are just Graphic Memory from android profiler in Android Studio

Beta goes to 0.7GB - 1GB

Master goes to 3.1GB Peak and 1.1GB constant.

EDIT
Dev goes to 2.1GB Peak and 1.1GB constant.

EDIT
Stable goes to 2.1GB Peak and 1.1GB constant.

Memory won't get freed even after canvas clear or widget dispose. Unless the app is turned off.

@hey24sheep
Copy link
Contributor

I am facing this same issue. Also if you put the app in the background, GC will run but Graphic Memory won't get freed. How can we solve this issue for the time being?

@zoechi zoechi added the dependency: skia Skia team may need to help us label Jan 21, 2019
@hey24sheep
Copy link
Contributor

There is a work around to clear graphics memory.

To clear the graphics memory,

  • First trick : you could draw empty data to canvas twice, it will free up graphics memory on the second draw. Sometimes you have to draw data more than 2 times.

  • Second trick : you could draw a small point on canvas and then draw empty data on canvas.

Both of these things will clear the graphics memory

@jason-simmons
Copy link
Member

This started when CCPR was enabled in Skia: google/skia@a2b5b64

@csmartdalton86

@chinmaygarde
Copy link
Member

CCPR has been disabled.

@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 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) dependency: skia Skia team may need to help us engine flutter/engine repository. See also e: labels. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

No branches or pull requests

5 participants