Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[Android] Revert WeexFrame (#2912)
Browse files Browse the repository at this point in the history
* Revert "[Android] Fix Crash in NotifyLayout (#2902)"

This reverts commit 5e8d9ac.

* Update submodule
  • Loading branch information
YorkShen authored and lucky-chen committed Sep 17, 2019
1 parent 5de6b6b commit 3337bc8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 33 deletions.
52 changes: 23 additions & 29 deletions android/sdk/src/main/java/com/taobao/weex/WeexFrameRateControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
import android.os.Build;
import android.util.Log;
import android.view.Choreographer;
import com.taobao.weex.bridge.WXBridgeManager;
import com.taobao.weex.common.WXErrorCode;
import java.lang.ref.WeakReference;

public class WeexFrameRateControl {
private static final long VSYNC_FRAME = 1000 / 60;
private WeakReference<VSyncListener> mListener;
private Choreographer mChoreographer;
private Choreographer.FrameCallback mVSyncFrameCallback;
private final Choreographer mChoreographer;
private final Choreographer.FrameCallback mVSyncFrameCallback;
private final Runnable runnable;

public interface VSyncListener {
Expand All @@ -44,32 +43,27 @@ public interface VSyncListener {
public WeexFrameRateControl(VSyncListener listener) {
mListener = new WeakReference<>(listener);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
WXBridgeManager.getInstance().post(new Runnable() {
@Override
public void run() {
mChoreographer = Choreographer.getInstance();
mVSyncFrameCallback = new Choreographer.FrameCallback() {
@SuppressLint("NewApi")
@Override
public void doFrame(long frameTimeNanos) {
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));
}
}
}
}
};
}
});
runnable = null;
mChoreographer = Choreographer.getInstance();
mVSyncFrameCallback = new Choreographer.FrameCallback() {
@SuppressLint("NewApi")
@Override
public void doFrame(long frameTimeNanos) {
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));
}
}
}
}
};
runnable = null;
} else {
// For API 15 or lower
runnable = new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
import android.support.annotation.RestrictTo.Scope;
import android.support.annotation.WorkerThread;
import android.support.annotation.UiThread;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.util.Log;
Expand Down Expand Up @@ -3461,15 +3461,15 @@ public void bindMeasurementToRenderObject(long ptr){
* @param instanceId
* @return
*/
@WorkerThread
@UiThread
public boolean notifyLayout(String instanceId) {
if (isSkipFrameworkInit(instanceId) || isJSFrameworkInit()) {
return mWXBridge.notifyLayout(instanceId);
}
return false;
}

@WorkerThread
@UiThread
public void forceLayout(String instanceId) {
if (isSkipFrameworkInit(instanceId) || isJSFrameworkInit()) {
mWXBridge.forceLayout(instanceId);
Expand Down

0 comments on commit 3337bc8

Please sign in to comment.