Skip to content

24fps (noticeable) when opening animation demo on Nexus 5 #9219

Closed

Description

@sethladd

There is a noticeable un-smoothness when opening the animation demo.

Make a release build of the gallery, open animation demo:

screenshot_20170405-103110

Activity

  1. added
    customer: galleryRelating to flutter/gallery repository. Please transfer non-framework issues there.
    c: performanceRelates to speed or footprint issues (see "perf:" labels)
    on Apr 5, 2017
  2. sethladd commented on Apr 5, 2017

    @sethladd
    ContributorAuthor

    For reference, here are the spikes when opening pesto, shrine, and contacts:

    screenshot_20170405-103355

  3. eseidelGoogle commented on Apr 6, 2017

    @eseidelGoogle
    Contributor

    Seth believes this should block an updated release of the gallery. The next build is slated to being release verification next week, so we'd need to fix this by then.

  4. sethladd commented on Apr 6, 2017

    @sethladd
    ContributorAuthor

    On a Moto G4 (the lower-bound of our Android phone target) we see 22fps when opening any component/widget demo (not just the vignettes)

    screenshot_20170406-132553

  5. eseidelGoogle commented on Apr 11, 2017

    @eseidelGoogle
    Contributor

    @chinmaygarde do you know if we upload images async to the GPU? Just musing at Triage about why these huge spikes might exist.

  6. chinmaygarde commented on Apr 11, 2017

    @chinmaygarde
    Contributor

    It is the raster cache snapshotting huge portions of the hierarchy when the animation is about to start and settle at either end. This work is expensive and completely unnecessary.

    screen shot 2017-04-11 at 3 31 35 pm

  7. chinmaygarde commented on Apr 11, 2017

    @chinmaygarde
    Contributor

    I investigated this further. Though the extra snapshotting work does take time, it is not the bottleneck. The SkCanvas::Flush itself takes a long time. This suggests we are simply making too many draw calls to the GPU. We need to simplify the scene.

    screen shot 2017-04-11 at 4 45 49 pm

  8. ScottPierce commented on Apr 11, 2017

    @ScottPierce

    @chinmaygarde So that means that the scene has hit the limit of what Flutter can do on the phone? Are there any other potential areas of optimization?

  9. eseidelGoogle commented on Apr 12, 2017

    @eseidelGoogle
    Contributor

    @chinmaygarde so next step is to look at the skpicture? Or where would we look next for reducing draw calls? What sort of tooling/logging should we add to understand situations like this?

  10. Hixie commented on Apr 12, 2017

    @Hixie
    Contributor

    In that screenshot, we're being descheduled for a really long time. The flush is long, but not THAT long.

    Can we break down what's in the scene and how expensive each operation is? It doesn't seem that complicated superficially. It has very little text, for instance. A few gradients, a few rectangles, some images.

  11. chinmaygarde commented on Apr 12, 2017

    @chinmaygarde
    Contributor
  12. sethladd commented on Apr 17, 2017

    @sethladd
    ContributorAuthor

    Thanks for doing the research!

  13. 7 remaining items

  14. Hixie commented on Apr 19, 2017

    @Hixie
    Contributor

    I would very much prefer if we kept the fade animation... it's what other Android apps do on those devices.

  15. chinmaygarde commented on Apr 19, 2017

    @chinmaygarde
    Contributor

    it's what other Android apps do on those devices.

    While @sethladd, @xster and I were tooling around on the device, we saw that the behavior was inconsistent. The contacts app had the slide transition while some parts of Google Play Music had the fade.

    In any case, if really like the fade transition, we can also introduce a picture layer boundary at that point in the hierarchy and make that picture be eligible for participation into the raster cache. We would pay the cost of populating the raster cache entry once (and may skip a frame or two on less powerful hardware) but subsequent frames would be fine. I'll submit patches for both tomorrow and we can just keep the one we like.

  16. sethladd commented on Apr 19, 2017

    @sethladd
    ContributorAuthor

    I would very much prefer if we kept the fade animation... it's what other Android apps do on those devices.

    Once we make it fast, we should add it back. It looks really nice.

  17. Hixie commented on Apr 19, 2017

    @Hixie
    Contributor

    I thought Opacity already always introduced a repaint boundary.

  18. chinmaygarde commented on Apr 19, 2017

    @chinmaygarde
    Contributor

    I thought Opacity already always introduced a repaint boundary.

    That is not true.

    Update:

    • This pull request should make the transitions on all demos fast.
    • The perf issue on the Animations demo can be fixed by removing this opacity widget and expressing the effect in terms of a custom color and blend mode. RenderImage currently hard codes the blend mode to BlendMode.srcIn. @HansMuller is working on making that configurable. He says he will be done with that by today. We can then fix the demo to use the new stuff.
    • If we need to release the demo before Hans is able to land the fix, we can manually change the opacity of the images on the section tabs (they are in the asset bundle) and remove the opacity layer. That should give us equivalent performance but is obviously a hack.
    • Issues of this class will be caught earlier in the future once we enable a debugging option where offscreen rendered layers are checker-boarded. The issue tracking the implementation of that option has been filed here.
    • The particular issue of the tabs in the animations demo (single child in an opacity layer) can also be detected by flow and an optimization applied where the render target switch is avoided in favor of achieving the same effect via paint options (like the one we are manually applying in this case). The issue tracking the implementation of that optimization is filed here.
  19. Hixie commented on Apr 19, 2017

    @Hixie
    Contributor

    https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/rendering/proxy_box.dart#L709
    ...says that Opacity will generate a new layer whenever the opacity is not 100% or 0%. At 100% it just passes everything through unmodified. At 0% it doesn't render anything.

    Is this not working?

  20. chinmaygarde commented on Apr 19, 2017

    @chinmaygarde
    Contributor

    Ah, I see. I was looking at isRepaintBoundary on RenderObject. But, even if a picture layer is introduced, the raster cache may disregard it for caching purposes if the op count of the picture is low enough (which it is in this case because there is only child). To force the raster cache to always cache the picture, you would need to set the isComplexHint on the same. I am hesitant to set that hint for this particular layer because doing it correctly via a paint in a flow optimization is better than making the raster cache populate an entry for us. Populating the raster cache entry will incur a hit initially and will also take up extra memory.

    Ideally, the user will use the performance debugging tools to avoid creating unnecessary opacity layers. In case that is not the case, the flow optimizations should catch most remaining cases.

  21. xster commented on Apr 19, 2017

    @xster
    Contributor

    In the case of the transitions, there's only one Opacity widget in the app if I understand correctly right? We should let users have one opacity without having to do performance debugging and removing the opacity.

  22. Hixie commented on Apr 19, 2017

    @Hixie
    Contributor

    I don't think we can count on our users doing anything involving profiling FadeTransitions, especially those involved in a MaterialPageRoute. They're going to want to assume that Just Works.

  23. chinmaygarde commented on Apr 19, 2017

    @chinmaygarde
    Contributor

    Hmm, even with the flow optimizations, we will only be able to handle cases where the fade is applied to a pictures that have a child (or maybe multiple children that themselves have no children, and, don't overlap). Using FadeTransitions on nested hierarchies excessively will cause performance bottlenecks. Some profiling there is unavoidable.

  24. Hixie commented on Apr 19, 2017

    @Hixie
    Contributor

    I don't really follow. What do you want the end user to do?

    To put it another way, what is the fix here for us to re-enable this?

  25. self-assigned this
    on Apr 19, 2017
  26. github-actions commented on Sep 5, 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.

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

Metadata

Metadata

Labels

c: performanceRelates to speed or footprint issues (see "perf:" labels)customer: galleryRelating to flutter/gallery repository. Please transfer non-framework issues there.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions