bluesky-social / social-app

The Bluesky Social application for Web, iOS, and Android
https://bsky.app
MIT License
12.63k stars 1.61k forks source link

Optimize ContentHider #6501

Closed gaearon closed 1 week ago

gaearon commented 1 week ago

Currently inside the ContentHider we're running a lot of Hooks (which read context, loop through stuff, create intermediate object, memoize them, and so on). However, none of those values are used if there's no actual blurring.

I'm splitting the component in two. The top part is a fast path if there's no blurring.

Note that this means that if the "has blur" condition flips somehow while the component is onscreen (is this possible?), the state of the inner component will reinintialize from scratch. I'm not sure whether this is an issue.

Test Plan

Verify both blurred and non-blurred posts show up. (You'll need to find some posts that are blurred under your settings.)

Before

The ContentHider self-time shows up in traces:

Screenshot 2024-11-18 at 17 08 59

After

The ContentHider self-time doesn't show up in traces:

Screenshot 2024-11-18 at 17 10 15
github-actions[bot] commented 1 week ago
Old size New size Diff
8.05 MB 8.05 MB 390 B (0.00%)