VEX-7094: Android: Crash in ReactExoplayerView.java Line 694 (#30)

When moving init logic to a different thread we missed one function that was not captured if an error occurred. This PR wraps the source init function that happens on a different thread in a try/catch to capture any errors that occur.
This commit is contained in:
Armands Malejev 2022-05-06 00:10:55 +03:00 committed by GitHub
parent 9035e7dfc9
commit c584022d34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -540,8 +540,15 @@ class ReactExoplayerView extends FrameLayout implements
// Initialize handler to run on the main thread
activity.runOnUiThread(new Runnable() {
public void run() {
// Source initialization must run on the main thread
initializePlayerSource(self, drmSessionManager);
try {
// Source initialization must run on the main thread
initializePlayerSource(self, drmSessionManager);
} catch (Exception ex) {
self.playerNeedsSource = true;
Log.e("ExoPlayer Exception", "Failed to initialize Player!");
Log.e("ExoPlayer Exception", ex.toString());
self.eventEmitter.error(ex.toString(), ex, "1001");
}
}
});
}
@ -620,7 +627,7 @@ class ReactExoplayerView extends FrameLayout implements
private void initializePlayerSource(ReactExoplayerView self, DrmSessionManager drmSessionManager) {
ArrayList<MediaSource> mediaSourceList = buildTextSources();
MediaSource videoSource = buildMediaSource(srcUri, extension, drmSessionManager);
MediaSource videoSource = buildMediaSource(self.srcUri, self.extension, drmSessionManager);
MediaSource mediaSource;
if (mediaSourceList.size() == 0) {
mediaSource = videoSource;