Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit f34709f3 authored by Aurélien Pomini's avatar Aurélien Pomini
Browse files

Add a recycle check in WallpaperLocalColorExtractor

Alternative to ag/24403729.

First, this CL makes ImageWallpaper and WallpaperLocalColorExtractor
share the same lock.

Sharing the same lock simplifies the concurrency logic. Since both
ImageWallpaper and WallpaperLocalColorExtractor use the same
single-threaded @LongExecutor for their long operations, their
operations are already atomic but this is rather implicit. We make this
explicit by sharing the same lock.

Second, we add a recycle() check before calling createScaledBitmap in
WallpaperLocalColorExtractor, to avoid a concurrency bug where a new
image is loaded by ImageWallpaper before the color extraction of the
previous image could take place.

By sharing the lock, ImageWallpaper does (recycle(), mBitmap=newBitmap,
startColorExtraction(mBitmap)) atomically with regard to
WallpaperLocalColorExtractor. So when trying to extract colors, we
are guaranteed that either the bitmap is the most recent one, either it
is recycled.

Bug: 292492981
Test: atest ImageWallpaperTest
Test: atest WallpaperLocalColorExtractorTest
Change-Id: Ib5bccaaa7ebb4371feccfc7f5c8407410b8ba59b
parent 53a70ac4
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment