Skip to content

Commit 7bb0afd

Browse files
committed
Improve logging by including full stack trace, and add release note
1 parent 820278c commit 7bb0afd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

RELEASENOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@
9797
* Fix bug where `MediaMetadata` was only populated from Vorbis comments
9898
with upper-case keys
9999
([#876](https://github.com/androidx/media/issues/876)).
100+
* Catch `OutOfMemoryError` when parsing very large ID3 frames, meaning
101+
playback can continue without the tag info instead of playback failing
102+
completely.
100103
* DRM:
101104
* Extend workaround for spurious ClearKey `https://default.url` license
102105
URL to API 33+ (previously the workaround only applied on API 33

libraries/extractor/src/main/java/androidx/media3/extractor/metadata/id3/Id3Decoder.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ public interface FramePredicate {
6464

6565
/** The first three bytes of a well formed ID3 tag header. */
6666
public static final int ID3_TAG = 0x00494433;
67-
6867
/** Length of an ID3 tag header. */
6968
public static final int ID3_HEADER_LENGTH = 10;
7069

@@ -372,8 +371,8 @@ private static Id3Frame decodeFrame(
372371
frameSize = removeUnsynchronization(id3Data, frameSize);
373372
}
374373

375-
String error = "";
376374
Id3Frame frame = null;
375+
Throwable error = null;
377376
try {
378377
if (frameId0 == 'T'
379378
&& frameId1 == 'X'
@@ -431,10 +430,8 @@ private static Id3Frame decodeFrame(
431430
String id = getFrameId(majorVersion, frameId0, frameId1, frameId2, frameId3);
432431
frame = decodeBinaryFrame(id3Data, frameSize, id);
433432
}
434-
} catch (Exception e) {
435-
error = ",error=" + e.getMessage();
436-
} catch (OutOfMemoryError e) {
437-
error = ",error=" + e.getMessage();
433+
} catch (OutOfMemoryError | Exception e) {
434+
error = e;
438435
} finally {
439436
id3Data.setPosition(nextFramePosition);
440437
}
@@ -444,8 +441,8 @@ private static Id3Frame decodeFrame(
444441
"Failed to decode frame: id="
445442
+ getFrameId(majorVersion, frameId0, frameId1, frameId2, frameId3)
446443
+ ", frameSize="
447-
+ frameSize
448-
+ error);
444+
+ frameSize,
445+
error);
449446
}
450447
return frame;
451448
}

0 commit comments

Comments
 (0)