Skip to content

Conversation

@jonathanmos
Copy link
Member

@jonathanmos jonathanmos commented Nov 26, 2025

What does this PR do?

Navigation3 bumps the compose-ui dependency to 1.9. Whereas previously we could get argb8888 from vectorDrawables with version 1.5, with 1.9 we get alpha8. In this pr, we convert the alpha8 mask into a grayscale bitmap, using the alpha transparency to set the level of gray. This means we lose color information but we have a performant method to keep supporting svgs.

@jonathanmos jonathanmos force-pushed the jmoskovich/PANA-5027/fix-alpha8 branch from 2c9ea68 to d9ee674 Compare November 26, 2025 14:42
@datadog-official
Copy link

datadog-official bot commented Nov 26, 2025

🎯 Code Coverage
Patch Coverage: 0.00%
Total Coverage: 71.26% (-0.07%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 12c1163 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@codecov-commenter
Copy link

codecov-commenter commented Nov 26, 2025

Codecov Report

❌ Patch coverage is 28.81356% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.12%. Comparing base (cf41629) to head (12c1163).
⚠️ Report is 22 commits behind head on develop.

Files with missing lines Patch % Lines
...lay/compose/internal/utils/BitmapCreationHelper.kt 5.13% 36 Missing and 1 partial ⚠️
...ionreplay/compose/internal/utils/SemanticsUtils.kt 75.00% 1 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3027      +/-   ##
===========================================
- Coverage    71.19%   71.12%   -0.07%     
===========================================
  Files          859      860       +1     
  Lines        31443    31492      +49     
  Branches      5302     5307       +5     
===========================================
+ Hits         22383    22396      +13     
- Misses        7560     7584      +24     
- Partials      1500     1512      +12     
Files with missing lines Coverage Δ
...ionreplay/compose/internal/utils/SemanticsUtils.kt 69.35% <75.00%> (+1.22%) ⬆️
...lay/compose/internal/utils/BitmapCreationHelper.kt 5.13% <5.13%> (ø)

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jonathanmos jonathanmos marked this pull request as ready for review November 27, 2025 12:28
@jonathanmos jonathanmos requested review from a team as code owners November 27, 2025 12:28
Comment on lines +22 to +24
private val logger: InternalLogger =
(Datadog.getInstance() as? FeatureSdkCore)?.internalLogger
?: InternalLogger.UNBOUND
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is possible to have internalLogger from the particular SDK instance?

Comment on lines +46 to +51
// Fill with Black (Transparency -> Black pixel)
canvas.drawColor(android.graphics.Color.BLACK)
val paint = Paint()
// Draw content in White (Opacity -> White pixel)
// Intermediate alpha levels will blend to create shades of gray (Grayscale)
paint.color = android.graphics.Color.WHITE
Copy link
Member

@0xnm 0xnm Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite get this and comments. As I understand, drawing black and white for Bitmap.Config.ALPHA_8 somehow creates grayscale since this config contains only alpha information.

But this method doesn't check that we get Bitmap.Config.ALPHA_8 config for the input.

Copy link
Member Author

@jonathanmos jonathanmos Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the key is in this line:

canvas.drawBitmap(source, 0f, 0f, paint)

because source is the alpha8 mask. When the paint is applied to this mask the alpha channel will cause the shades. We only reach this method through createBitmapFromAlpha8 in semanticsUtil, so we know that the source will necessarily be an alpha8 mask. I'll change the name of the class or method to make it clear that it is only for alpha8 processing.

throwable = e
)
null
} catch (e: OutOfMemoryError) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we catch OOM exception specifically here?

(Datadog.getInstance() as? FeatureSdkCore)?.internalLogger
?: InternalLogger.UNBOUND
) : BitmapCreationHelper {
override fun createBitmap(width: Int, height: Int, config: Bitmap.Config): Bitmap {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this function only calls Bitmap.createBitmap and return it, and in the callsite it directly chains with drawBitmap, so why can't we have a single function create inline this one?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants