Skip to content

High GPU consumption with Rive/Flare Animation  #57686

Closed

Description

@jasonch99

High GPU consumption when playing a Rive/Flare animation.
Tested on Google Nest hub device and saw GPU cost ~50-60%.
The recorded SKP showed lots of drawPath and clipPath.

Minimal reproduction app : https://github.com/jasonch99/testRiveAnimation
The app simply loads and plays the animation.

Screen Shot 2020-05-20 at 1 10 15 PM

Activity

  1. added
    perf: energyPerformance issues related to energy use (power, watts)
    c: performanceRelates to speed or footprint issues (see "perf:" labels)
    on May 21, 2020
  2. liyuqian commented on May 21, 2020

    @liyuqian
    Contributor

    How did you measure the GPU usage, @jasonch99 ? I'm having a little difficulty in finding an Android tool that can report the GPU usage.

  3. jasonch99 commented on May 21, 2020

    @jasonch99
    Author

    The GPU usage I measured was on Nest Hub device with this command
    cat /sys/class/mpgpu/utilization

    I am not sure if there is anything similar on Android.

  4. added
    engineflutter/engine related. See also e: labels.
    on Jul 1, 2020
  5. added
    P2Important issues not at the top of the work list
    on Jul 6, 2020
  6. zanderso commented on Jul 6, 2020

    @zanderso
    Member

    @liyuqian is this issue actionable?

  7. liyuqian commented on Jul 9, 2020

    @liyuqian
    Contributor

    Yes, the Android team just told me how to measure GPU usage on Android. I'll take some time to investigate and perhaps schedule a meeting with Rive/Flare.

  8. added this to the 1.26 - December 2020 milestone on Jul 9, 2020
  9. liyuqian commented on Sep 3, 2020

    @liyuqian
    Contributor

    Remove myself from the assignment as I'm not actively working on this. Will reassign myself once I get some time to work on it.

  10. removed their assignment
    on Sep 3, 2020
  11. liyuqian commented on Nov 13, 2020

    @liyuqian
    Contributor

    I ran python $ANDROID_SDK_ROOT/platform-tools/systrace/systrace.py -t 10 freq and checked the gfx3d_clk_src frequency on my Moto G4. The device has Adreno 405 GPU with a max frequency of 550MHz. The traced frequency is constantly above 400MHz as shown in the screeshot:
    Screen Shot 2020-11-12 at 8 29 14 PM

    The frequency would be a good indicator of the GPU usage on Android. So the high usage not only happens on Nest Hub, but also on normal Android devices.

    After checking with flutter run ... --trace-skia, I found that the frame rasterization time is constantly above 30ms. Two paths take more than 1ms/path to finish SkCanvas::drawPath call before even calling SkCanvas::flush.

    Screen Shot 2020-11-12 at 8 34 20 PM

    I suspect it's related with the path that's either drawn with saveLayer blurs. See the attached SKP and its 14th draw op DrawPath when opened with https://debugger.skia.org
    flutter_02.skp.zip

  12. liyuqian commented on Nov 13, 2020

    @liyuqian
    Contributor

    @jasonch99 : can you please check if the GPU usage can be reduced by removing and tweaking some of those expensive paths in the Rive animation? If those path or effects can't be removed, maybe we need to loop in Skia or Rive team to figure out if there's any optimization to do. One possible optimization is to enable more raster cache on Rive paths (e.g., the blurred path seem to be static to me). CC @luigi-rosso who just discussed the raster cache with us yesterday about Jim's promising work on flutter-team-archive/engine#21943.

  13. jasonch99 commented on Nov 13, 2020

    @jasonch99
    Author

    Is the expensive part the shadow here?
    Screen Shot 2020-11-13 at 11 46 29 AM

  14. liyuqian commented on Nov 13, 2020

    @liyuqian
    Contributor

    Yes, that's my guess.

  15. jasonch99 commented on Nov 30, 2020

    @jasonch99
    Author

    I tested the same animation with no blur, it reduced the GPU cost.
    I will see if we can remove the shadow or use a shadow without blur.

  16. jasonch99 commented on Dec 2, 2020

    @jasonch99
    Author

    We can remove the shadow blur for our animations.

    liyuqian@, assigning this back to you to see if we want to implement the raster cache solution you mentioned earlier in case other animations may need it.

  17. removed their assignment
    on Dec 2, 2020
  18. zanderso commented on Dec 2, 2020

    @zanderso
    Member

    I'm going to close this. It sounds like that current issue is resolved, and if we need to enable more raster caching of Rive paths, we can track that in a separate, new issue. Please feel free to reopen with further details if I'm mistaken.

  19. github-actions commented on Aug 9, 2021

    @github-actions

    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.

  20. locked as resolved and limited conversation to collaborators on Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: performanceRelates to speed or footprint issues (see "perf:" labels)customer: dream (g3)engineflutter/engine related. See also e: labels.perf: energyPerformance issues related to energy use (power, watts)

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions