Skip to content

Commit 05a5256

Browse files
committed
Attempt to group OOM's generated by HtspDataSource
HtspDataSource allocates a large buffer, so it's v.likely to fail due to an OOM. Lets try to group these better in crashreporting, by catching and instead raising an RuntimeException.
1 parent ad31877 commit 05a5256

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.idea/modules.xml

-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/ie/macinnes/tvheadend/player/HtspDataSource.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,16 @@ public HtspDataSource(Context context, SimpleHtspConnection connection, String s
8282
mConnection = connection;
8383
mStreamProfile = streamProfile;
8484

85-
mBuffer = ByteBuffer.allocate(BUFFER_SIZE);
86-
mBuffer.limit(0);
85+
try {
86+
mBuffer = ByteBuffer.allocate(BUFFER_SIZE);
87+
mBuffer.limit(0);
88+
} catch (OutOfMemoryError e) {
89+
// Since we're allocating a large buffer here, it's fairly safe to assume we'll have
90+
// enough memory to catch and throw this exception. We do this, as each OOM exception
91+
// message is unique (lots of #'s of bytes available/used/etc) and means crash reporting
92+
// doesn't group things nicely.
93+
throw new RuntimeException("OutOfMemoryError when allocating HtspDataSource buffer", e);
94+
}
8795

8896
mSubscriber = new Subscriber(mConnection, this);
8997
mConnection.addAuthenticationListener(mSubscriber);

0 commit comments

Comments
 (0)