You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@weex.apache.org by GitBox <gi...@apache.org> on 2018/09/14 08:32:28 UTC

[GitHub] YorkShen closed pull request #1518: * [Android] Downgrade to h5 if unsatisfiedLinked error happened

YorkShen closed pull request #1518: * [Android] Downgrade to h5 if unsatisfiedLinked error happened
URL: https://github.com/apache/incubator-weex/pull/1518
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/android/sdk/src/main/java/com/taobao/weex/WeexFrameRateControl.java b/android/sdk/src/main/java/com/taobao/weex/WeexFrameRateControl.java
index 61f47eb09f..d8fc60b473 100644
--- a/android/sdk/src/main/java/com/taobao/weex/WeexFrameRateControl.java
+++ b/android/sdk/src/main/java/com/taobao/weex/WeexFrameRateControl.java
@@ -22,10 +22,11 @@
  * Created by shiwentao on 2017/8/24.
  */
 
-import android.annotation.TargetApi;
+import android.annotation.SuppressLint;
 import android.os.Build;
+import android.util.Log;
 import android.view.Choreographer;
-
+import com.taobao.weex.common.WXErrorCode;
 import java.lang.ref.WeakReference;
 
 public class WeexFrameRateControl {
@@ -44,11 +45,21 @@ public WeexFrameRateControl(VSyncListener listener) {
         if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
             mChoreographer = Choreographer.getInstance();
             mVSyncFrameCallback = new Choreographer.FrameCallback() {
+                @SuppressLint("NewApi")
                 @Override
                 public void doFrame(long frameTimeNanos) {
-                    mChoreographer.postFrameCallback(mVSyncFrameCallback);
-                    if (mListener != null && mListener.get() != null) {
-                        mListener.get().OnVSync();
+                    VSyncListener vSyncListener;
+                    if (mListener != null && (vSyncListener=mListener.get()) != null) {
+                        try {
+                            vSyncListener.OnVSync();
+                            mChoreographer.postFrameCallback(mVSyncFrameCallback);
+                        }catch (UnsatisfiedLinkError e){
+                            if(vSyncListener instanceof WXSDKInstance){
+                                ((WXSDKInstance) vSyncListener).onRenderError(
+                                    WXErrorCode.WX_DEGRAD_ERR_INSTANCE_CREATE_FAILED.getErrorCode(),
+                                    Log.getStackTraceString(e));
+                            }
+                        }
                     }
                 }
             };
@@ -58,9 +69,18 @@ public void doFrame(long frameTimeNanos) {
             runnable = new Runnable() {
                 @Override
                 public void run() {
-                    WXSDKManager.getInstance().getWXRenderManager().postOnUiThread(runnable, VSYNC_FRAME);
-                    if (mListener != null && mListener.get() != null) {
-                        mListener.get().OnVSync();
+                    VSyncListener vSyncListener;
+                    if (mListener != null && (vSyncListener = mListener.get()) != null) {
+                        try {
+                            vSyncListener.OnVSync();
+                        }catch (UnsatisfiedLinkError e){
+                            if(vSyncListener instanceof WXSDKInstance){
+                                ((WXSDKInstance) vSyncListener).onRenderError(
+                                    WXErrorCode.WX_DEGRAD_ERR_INSTANCE_CREATE_FAILED.getErrorCode(),
+                                    Log.getStackTraceString(e));
+                            }
+                        }
+                        WXSDKManager.getInstance().getWXRenderManager().postOnUiThread(runnable, VSYNC_FRAME);
                     }
                 }
             };
@@ -69,6 +89,7 @@ public void run() {
         }
     }
 
+    @SuppressLint("NewApi")
     public void start() {
         if (mChoreographer != null) {
             mChoreographer.postFrameCallback(mVSyncFrameCallback);
@@ -78,6 +99,7 @@ else if(runnable!=null){
         }
     }
 
+    @SuppressLint("NewApi")
     public void stop() {
         if (mChoreographer != null) {
             mChoreographer.removeFrameCallback(mVSyncFrameCallback);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services