thunder icon indicating copy to clipboard operation
thunder copied to clipboard

Reduce slow frames and jank

Open hjiangsu opened this issue 9 months ago • 1 comments

Is Your Feature Request Related to a Problem?

This is an umbrella issue to track PRs related to improving overall performance of Thunder, which includes reducing or eliminating sources of slow frames or jank that occurs while using the app.

Feature Description

The goal here is to find sources of jank, and optimize the slow frames to make the overall experience smoother. To scope it down, focus will be on the feed pages and related widgets to start. After that, we can put focus on the post page.

There are a few things we can do:

  1. Perform performance profiling to find cases of slow frames and jank
  2. Perform CPU profiling to find long running and expensive operations
  3. Find sources where we're triggering widget builds unnecessarily

This will take some trial and error as I'm not too familiar with doing performance profiling but hopefully others can chime in on how to better optimize app performance!

Some resources:

  • https://docs.flutter.dev/perf

Alternative Solutions

No response

Additional Context

The experience in Thunder seems to vary depending on the phone and operating system. For iOS, the experience is generally good with little or no stuttering or jank. However, the experience on Android differs depending on the specific device (possibly CPU).

I recently got access to a physical Android device (Pixel 9 Pro), so I can finally do some tests on a physical device.

hjiangsu avatar Mar 10 '25 18:03 hjiangsu

I'll place some observations and ideas here in case anyone would like to work on them! I'll also be updating this comment when I have more ideas.

  • [x] Remove VisibilityDetector from FeedPostCardList when 'Mark Read on Scroll' is not enabled. I believe VisibilityDetector performs some expensive calculations when trying to determine if a widget is within view.
  • [x] Use SliverList instead of SliverMasonryGrid when tablet mode is not enabled as it might be more performant.
  • [ ] Investigate the use of isolates for more expensive functions to move them off the UI thread.
  • [ ] Improve parsing of MediaView for text posts
  • [ ] Flatten widget layout tree for post metadata and author widgets

hjiangsu avatar Mar 10 '25 19:03 hjiangsu