Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APP2-72 #11

Open
wants to merge 2 commits into
base: crash_render_thread
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
}
Binary file modified android/libs/libjingle_peerconnection.so.jar
Binary file not shown.
Binary file modified android/libs/libwebrtc.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
36 changes: 13 additions & 23 deletions android/src/main/java/com/oney/WebRTCModule/WebRTCView.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
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;
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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down