Skip to content

Commit a708e08

Browse files
committed
fix(android): log warning when inferFromMagicBytes falls back to IMAGE, check WebP explicitly
1 parent bb06d88 commit a708e08

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

android/src/new/java/com/margelo/nitro/rive/ExperimentalAssetLoader.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,19 @@ object ExperimentalAssetLoader {
128128
data.startsWith(0x49, 0x44, 0x33) -> AssetType.AUDIO // MP3 (ID3)
129129
data.startsWith(0x00, 0x01, 0x00, 0x00) -> AssetType.FONT // TrueType
130130
data.startsWith(0x4F, 0x54, 0x54, 0x4F) -> AssetType.FONT // OpenType (OTTO)
131-
data.startsWith(0x52, 0x49, 0x46, 0x46) -> // RIFF container
131+
data.startsWith(0x52, 0x49, 0x46, 0x46) ->
132132
if (data.matchesAt(8, 0x57, 0x41, 0x56, 0x45)) {
133-
AssetType.AUDIO // → WAV (WAVE)
133+
AssetType.AUDIO // WAV (WAVE)
134+
} else if (data.matchesAt(8, 0x57, 0x45, 0x42, 0x50)) {
135+
AssetType.IMAGE // WebP (WEBP)
134136
} else {
135-
AssetType.IMAGE // → WebP
137+
Log.w(TAG, "Unknown RIFF asset, assuming IMAGE. Declare asset type explicitly to avoid this.")
138+
AssetType.IMAGE
136139
}
137-
else -> AssetType.IMAGE
140+
else -> {
141+
Log.w(TAG, "Could not infer asset type from magic bytes, assuming IMAGE. Declare asset type explicitly to avoid this.")
142+
AssetType.IMAGE
143+
}
138144
}
139145
}
140146

0 commit comments

Comments
 (0)