diff --git a/android/build.gradle b/android/build.gradle index b13256b4d..69bb10eba 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -28,6 +28,6 @@ android { dependencies { implementation 'com.facebook.react:react-native:+' - api 'com.bugsnag:bugsnag-android:4.22.3' + api 'com.bugsnag:bugsnag-android:5.2.2' api fileTree(dir: 'libs', include: ['*.jar']) } diff --git a/android/libs/libjingle_peerconnection.so.jar b/android/libs/libjingle_peerconnection.so.jar index f4645ce4f..2a8406027 100644 Binary files a/android/libs/libjingle_peerconnection.so.jar and b/android/libs/libjingle_peerconnection.so.jar differ diff --git a/android/libs/libwebrtc.jar b/android/libs/libwebrtc.jar index 7cdea660a..73d282dfe 100644 Binary files a/android/libs/libwebrtc.jar and b/android/libs/libwebrtc.jar differ diff --git a/android/src/main/java/com/oney/WebRTCModule/UnSurfaceViewRenderer.java b/android/src/main/java/com/oney/WebRTCModule/UnSurfaceViewRenderer.java index 53db466dc..efdef0947 100644 --- a/android/src/main/java/com/oney/WebRTCModule/UnSurfaceViewRenderer.java +++ b/android/src/main/java/com/oney/WebRTCModule/UnSurfaceViewRenderer.java @@ -14,6 +14,7 @@ import java.util.concurrent.CountDownLatch; import org.webrtc.EglBase; +import org.webrtc.EglError; import org.webrtc.EglRenderer; import org.webrtc.EglRenderer.FrameListener; import org.webrtc.GlRectDrawer; @@ -43,9 +44,9 @@ public class UnSurfaceViewRenderer extends SurfaceView implements Callback, Vide private int surfaceWidth; private int surfaceHeight; - public UnSurfaceViewRenderer(Context context) { + public UnSurfaceViewRenderer(Context context, EglError eglError) { super(context); - this.eglRenderer = new EglRenderer(this.resourceName); + this.eglRenderer = new EglRenderer(this.resourceName, eglError); this.getHolder().addCallback(this); // this.setZOrderMediaOverlay(true); // this.getHolder().setFormat(PixelFormat.TRANSPARENT); diff --git a/android/src/main/java/com/oney/WebRTCModule/WebRTCGreenScreenView.java b/android/src/main/java/com/oney/WebRTCModule/WebRTCGreenScreenView.java index 0b3900dfb..e3a6613b8 100644 --- a/android/src/main/java/com/oney/WebRTCModule/WebRTCGreenScreenView.java +++ b/android/src/main/java/com/oney/WebRTCModule/WebRTCGreenScreenView.java @@ -1,29 +1,32 @@ package com.oney.WebRTCModule; import android.annotation.SuppressLint; -import android.content.res.Resources; import android.content.Context; import android.graphics.Color; import android.graphics.Point; -import androidx.core.view.ViewCompat; +import android.util.Log; import android.view.View; import android.view.ViewGroup; -import android.util.Log; +import android.widget.Toast; + +import androidx.core.view.ViewCompat; import com.bugsnag.android.Bugsnag; +import com.bugsnag.android.Severity; import com.facebook.react.bridge.ReactContext; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.List; - import org.webrtc.EglBase; +import org.webrtc.EglError; import org.webrtc.MediaStream; import org.webrtc.RendererCommon; import org.webrtc.RendererCommon.RendererEvents; import org.webrtc.RendererCommon.ScalingType; import org.webrtc.VideoTrack; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; + public class WebRTCGreenScreenView extends ViewGroup { /** * The scaling type to be utilized by default. @@ -170,7 +173,16 @@ public void run() { public WebRTCGreenScreenView(Context context) { super(context); - surfaceViewRenderer = new UnSurfaceViewRenderer(getContext()); + surfaceViewRenderer = new UnSurfaceViewRenderer(getContext(), new EglError() { + @Override + public void onSurfaceCreationFailed(Exception e) { + Toast.makeText(context, "Error in loading video. Please reopen the class", Toast.LENGTH_LONG).show(); + Bugsnag.notify(e, event -> { + event.setSeverity(Severity.INFO); + return true; + }); + } + }); addView(surfaceViewRenderer); setMirror(true); setScalingType(DEFAULT_SCALING_TYPE); @@ -644,28 +656,6 @@ public void run() { } }); surfaceViewRenderer.init(sharedContext, rendererEvents, EglBase.CONFIG_RGBA, glDrawer); - try { - String threadName = ""; - try { - threadName = surfaceViewRenderer.getResources().getResourceEntryName(surfaceViewRenderer.getId()) + ": " + "EglRenderer"; - } catch (Resources.NotFoundException exception) { - threadName = "EglRenderer"; - } - Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() { - @Override - public void uncaughtException(Thread th, Throwable ex) { - if(ex.getMessage() != null) { - Bugsnag.notify("Webrtc green screen view error on thread: " + th.getName(), ex.getMessage(), ex.getStackTrace(), null); - } else { - Bugsnag.notify("Webrtc green screen view error on thread: " + th.getName(),"", ex.getStackTrace(), null); - } - surfaceViewRenderer.release(); - } - }; - ThreadUtils.addExceptionHandlerForThread(h, threadName); - } catch (Exception e) { - e.printStackTrace(); - } videoTrack.addSink(surfaceViewRenderer); rendererAttached = true; } diff --git a/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java b/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java index f715bb73d..9bdb8fda0 100644 --- a/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java +++ b/android/src/main/java/com/oney/WebRTCModule/WebRTCView.java @@ -9,8 +9,10 @@ import android.view.View; import android.view.ViewGroup; import android.util.Log; +import android.widget.Toast; import com.bugsnag.android.Bugsnag; +import com.bugsnag.android.Severity; import com.facebook.react.bridge.ReactContext; import java.lang.reflect.InvocationTargetException; @@ -18,6 +20,7 @@ import java.util.List; import org.webrtc.EglBase; +import org.webrtc.EglError; import org.webrtc.MediaStream; import org.webrtc.RendererCommon; import org.webrtc.RendererCommon.RendererEvents; @@ -170,7 +173,16 @@ public void run() { public WebRTCView(Context context) { super(context); - surfaceViewRenderer = new SurfaceViewRenderer(context); + surfaceViewRenderer = new SurfaceViewRenderer(context, new EglError() { + @Override + public void onSurfaceCreationFailed(Exception e) { + Toast.makeText(context, "Error in loading video. Please reopen the class", Toast.LENGTH_LONG).show(); + Bugsnag.notify(e, event -> { + event.setSeverity(Severity.INFO); + return true; + }); + } + }); addView(surfaceViewRenderer); setMirror(false); @@ -600,28 +612,6 @@ private void tryAddRendererToVideoTrack() { } surfaceViewRenderer.init(sharedContext, rendererEvents); - try { - String threadName = ""; - try { - threadName = surfaceViewRenderer.getResources().getResourceEntryName(surfaceViewRenderer.getId()) + "EglRenderer"; - } catch (Resources.NotFoundException exception) { - threadName = "EglRenderer"; - } - Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() { - @Override - public void uncaughtException(Thread th, Throwable ex) { - if(ex.getMessage() != null) { - Bugsnag.notify("Webrtc view error on thread: " + th.getName(), ex.getMessage(), ex.getStackTrace(), null); - } else { - Bugsnag.notify("Webrtc view error on thread: " + th.getName(), "", ex.getStackTrace(), null); - } - surfaceViewRenderer.release(); - } - }; - ThreadUtils.addExceptionHandlerForThread(h, threadName); - } catch (Exception e) { - e.printStackTrace(); - } videoTrack.addSink(surfaceViewRenderer); rendererAttached = true;