react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

Render cached images synchronously

Open marty-wang opened this issue 3 years ago • 2 comments
trafficstars

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Why

Previously the cached images still render asynchronously and therefore appear on the screen a few frames later than the adjacent UI, which results in flickers and flashes. The issue gets exacerbated on slower machines or when UI is busy.

What

In this PR I added a LRU cache which stores the loaded BitmapImage so that the image can render synchronously from the cache next time.

Screenshots

Below is the frame-by-frame playback for the before-and-after comparison.

Before: (Images appear after a few frames after the other UI has rendered)

https://user-images.githubusercontent.com/1132214/161341592-111b6412-07f0-44dc-8e86-5e876adcc401.mp4

After: (Images appear at the same time with the other UI)

https://user-images.githubusercontent.com/1132214/161341462-0bad8855-ffa0-4721-af6a-60fa61b069d2.mp4

Microsoft Reviewers: Open in CodeFlow

marty-wang avatar Apr 01 '22 21:04 marty-wang

Looks like your dev environment isn't picking up the clangformat rules automatically. You can run yarn format at the root to manually run them.

acoates-ms avatar Apr 01 '22 22:04 acoates-ms

How could I install this PR on my project?

nicoceledonc avatar Sep 10 '22 17:09 nicoceledonc

@marty-wang Are we able to add a QuirkSetting to this PR? I believe that's the only thing stopping us from merging it in.

TatianaKapos avatar Nov 17 '22 22:11 TatianaKapos

Hi @TatianaKapos, I am afraid that I won't have bandwidth to add QuirkSetting to this PR in the near future. Please feel free to commandeer this PR, or I am happy to release it to anyone who'd like to take it to the finish line. Thanks!

marty-wang avatar Nov 18 '22 00:11 marty-wang

@acoates-ms Just checking in about this PR since it's a little stale. Do we still want to add a QuirkSetting or has anything changed? If so, I can add it or we should close it out?

TatianaKapos avatar Dec 06 '22 20:12 TatianaKapos

@rozele @lyahdav Is this something that's still interesting from your end? The conversation here seemed to resolve that this should be quirked in order to be submitted.

chrisglein avatar Dec 14 '22 19:12 chrisglein

@chrisglein this is still something we have in our fork, but it's not gated with a quirk setting. We likely don't have the bandwidth to update the PR to be gated on a quirk setting in the short-term.

lyahdav avatar Dec 15 '22 22:12 lyahdav

It's likely that most of Messenger's image rendering will move to a custom component, so I think this can be closed out. Messenger has variants needed that are beyond the scope of core, like WebP support and this caching work.

rozele avatar Dec 20 '22 04:12 rozele

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

ghost avatar Dec 27 '22 06:12 ghost