File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
android/src/main/java/com/opentokreactnative Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 55import android .graphics .Canvas ;
66import android .os .Handler ;
77import android .view .View ;
8+ import android .os .Looper ;
89
910import com .opentok .android .BaseVideoCapturer ;
1011
@@ -21,15 +22,27 @@ public class OTScreenCapturer extends BaseVideoCapturer {
2122 private Bitmap bmp ;
2223 private Canvas canvas ;
2324
24- private Handler mHandler = new Handler ();
25+ private Handler mHandler = new Handler (Looper . getMainLooper () );
2526
2627 private Runnable newFrame = new Runnable () {
2728 @ Override
2829 public void run () {
2930 if (capturing ) {
31+ // Check if the view is attached and has dimensions
32+ if (contentView == null || !contentView .isAttachedToWindow ()) {
33+ mHandler .postDelayed (newFrame , 1000 / fps );
34+ return ;
35+ }
36+
3037 int width = contentView .getWidth ();
3138 int height = contentView .getHeight ();
3239
40+ // Skip frame if dimensions are zero
41+ if (width <= 0 || height <= 0 ) {
42+ mHandler .postDelayed (newFrame , 1000 / fps );
43+ return ;
44+ }
45+
3346 if (frame == null ||
3447 OTScreenCapturer .this .width != width ||
3548 OTScreenCapturer .this .height != height ) {
You can’t perform that action at this time.
0 commit comments