Skip to content

fix(android): stop Fresco "Don't know how to round that drawable" warnings on images - #58855

Open
franruiztech wants to merge 1 commit into
react:mainfrom
franruiztech:fix/android-image-download-listener-rounding
Open

franruiztech wants to merge 1 commit into
react:mainfrom
franruiztech:fix/android-image-download-listener-rounding

Conversation

@franruiztech

@franruiztech franruiztech commented Oct 5, 2026 •

Copy link
Copy Markdown

Summary:

When an <Image> has onProgress, onLoadStart, onLoad or onLoadEnd handlers, ReactImageView creates a ReactImageDownloadListener. This class doubles as the progress bar drawable of the Drawee hierarchy: it is a ForwardingDrawable wrapping a private EmptyDrawable.

ReactImageView builds its hierarchy with RoundingParams, and Fresco applies the rounding to the leaf of every child drawable (WrappingUtils.maybeApplyLeafRounding). It can only round bitmap, nine-patch and color drawables, so for EmptyDrawable it logs Don't know how to round that drawable at warn level (tag unknown:WrappingUtils). maybeUpdateViewFromRequest calls hierarchy.setProgressBarImage(downloadListener) on every update, and the hierarchy also re-applies rounding when the rounding params are set, so the line is printed repeatedly (173 times in a typical session on 0.85.3). Fresco reports the same thing for custom progress drawables in facebook/fresco#2369.

Two changes:

  1. ReactImageDownloadListener wraps ColorDrawable(Color.TRANSPARENT) instead of EmptyDrawable. Fresco can round it, and it still draws nothing. EmptyDrawable is removed.
  2. ReactImageView installs the progress bar image once per listener instead of on every update. This is needed as well: after the first call the leaf has become a RoundedColorDrawable, which is not a ColorDrawable, so Fresco would warn again on the next setProgressBarImage with the same listener. Setting an already installed drawable again has no other effect.

One behavior difference remains. Once Fresco rounds the leaf, the leaf is a transparent RoundedColorDrawable instead of the unrounded EmptyDrawable, so getOpacity() of the composite Drawee drawable goes from OPAQUE to TRANSPARENT for opaque images that have load handlers. As a result ImageView.isOpaque() goes from true to false for those views. Nothing is painted differently: the progress bar draws nothing either way, and the rest of the hierarchy is unchanged. Only code that reads the opacity (for example to skip drawing what is behind the view) sees the difference.

buildHierarchy and its RoundingParams.fromCornersRadius(0f) are left as they are.

Changelog:

[ANDROID] [FIXED] - Stop Fresco from logging "Don't know how to round that drawable" for images with load/progress events

Test Plan:

Added testProgressBarImageDoesNotWarnAboutRounding to ReactImagePropertyTest: it creates a ReactImageView, enables load events, runs maybeUpdateView twice with different sources, and checks that FLog.w is never called with Fresco's rounding message.

Ran it with ./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests com.facebook.react.views.image.ReactImagePropertyTest: 11 tests, all pass. I also put each half of the change back on its own and ran the same class again; each time only the new test fails, with NeverWantedButInvoked on FLog.w(String, "Don't know how to round that drawable: %s", Object) raised from WrappingUtils.applyLeafRounding:

  • EmptyDrawable back as the leaf, install-once kept: fails (the warning names ReactImageDownloadListener$EmptyDrawable).
  • ColorDrawable leaf kept, setProgressBarImage on every update: fails (the warning names RoundedColorDrawable).
  • Both put back: fails with three warnings over the two updates.

So both halves are needed and each one is covered by the test. Separately, I compiled the changed classes against the 0.85.3 react-android release AAR and replaced them in it; javap -p shows the public and internal API of ReactImageView and ReactImageDownloadListener is unchanged apart from the new private field and the removed private EmptyDrawable.

On an Android 9 (API 28) x86_64 emulator, with a release build of an app on 0.85.3 (R8, Hermes, New Architecture), I ran the same scripted flow twice: login, five tabs, a list with about 20 remote logos, a company detail screen, and a cold restart. I counted the matching logcat lines.

react-android Don't know how to round that drawable
stock 0.85.3 224 lines
0.85.3 with this patch (and the one for the generated setter warning) 0 lines

Stock 0.85.3 on API 26, 31, 33 and 36 gives 227 lines for the same flow. The patched build was run on API 28 and API 34 (Android 14), with 0 lines on both. It did not crash, the logos render with their rounded corners (checked on a screenshot), and the company detail screen works.

Not measured: the onLoad and onProgress events beyond the images being painted, and any API level other than 28 for the patched build.

The patched react-android was built by recompiling the changed classes and replacing them in the official 0.85.3 AAR, not with a full Gradle build of ReactAndroid.

…nings on images

ReactImageDownloadListener doubles as the progress bar drawable of the
image hierarchy, wrapping a private EmptyDrawable. ReactImageView builds
its hierarchy with RoundingParams, and Fresco applies those to the leaf
of every child drawable (WrappingUtils.maybeApplyLeafRounding). It only
knows how to round bitmap, nine-patch and color drawables, so for any
other leaf it logs "Don't know how to round that drawable" at warn level,
once for the progress bar plus once per later update.

Wrap a transparent ColorDrawable instead, which Fresco can round and
which still renders nothing.

ReactImageView also called setProgressBarImage with the same listener on
every update. After the first call the leaf is already a
RoundedColorDrawable, which is not a ColorDrawable, so Fresco would warn
again. Install the progress bar only when the listener changes.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 5, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 5, 2026
@franruiztech franruiztech changed the title fix(android): stop Fresco "Don't know how to round that drawable" war… fix(android): stop Fresco "Don't know how to round that drawable" warnings on images Oct 5, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant