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

replace Java WxTimerModule with C++ setTimeout/setInterval implementa… #232

Merged
merged 2 commits into from
Apr 13, 2017
Merged
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
Binary file modified android/sdk/libs/armeabi/libweexv8.so
Binary file not shown.
8 changes: 8 additions & 0 deletions android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,7 @@ public void onActivityDestroy() {
WXLogUtils.w("Warning :Component tree has not build completely, onActivityDestroy can not be call!");
}

destroyUnhandledTimer();
destroy();
}

Expand Down Expand Up @@ -1270,6 +1271,13 @@ private void destroyView(View rootView) {
}
}

/**
* destroy all unhandled c++ setTimeout/setInterval callback
*/
public void destroyUnhandledTimer(){
WXBridgeManager.getInstance().clearInstanceCallback(mInstanceId);
}

public synchronized void destroy() {
WXSDKManager.getInstance().destroyInstance(mInstanceId);
WXComponentFactory.removeComponentTypesByInstanceId(getInstanceId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ class WXBridge implements IWXBridge {
*/
public native void takeHeapSnapshot(String filename);


/**
* Called to clear all unhandled c++ timer when an instance is
* destroyed
* @param instanceId the destoyed instance's id.
*/
public native void clearInstanceCallback(String instanceId);

/**
* JavaScript uses this methods to call Android code
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public int callNative(String instanceId, String tasks, String callback) {
if (WXEnvironment.isApkDebugable()) {
mLodBuilder.append("[WXBridgeManager] callNative >>>> instanceId:").append(instanceId)
.append(", tasks:").append(tasks).append(", callback:").append(callback);
WXLogUtils.d(mLodBuilder.substring(0));

mLodBuilder.setLength(0);
}

Expand Down Expand Up @@ -1069,7 +1069,7 @@ public void invokeExecJS(String instanceId, String namespace, String function,
.append("function:").append(function);
if(logTaskDetail)
mLodBuilder.append(" tasks:").append(WXJsonUtils.fromObjectToJSONString(args));
WXLogUtils.d(mLodBuilder.substring(0));

mLodBuilder.setLength(0);
}
mWXBridge.execJS(instanceId, namespace, function, args);
Expand Down Expand Up @@ -1341,6 +1341,10 @@ private void invokeRegisterComponents(List<Map<String, Object>> components, List
}
}

public void clearInstanceCallback(String instanceId){
mWXBridge.clearInstanceCallback(instanceId);
}

public void destroy() {
if (mJSThread != null) {
mJSThread.quit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ public interface IWXBridge extends IWXObject {
*/
void takeHeapSnapshot(String filename);

void clearInstanceCallback(String instanceId);

/**
* js call native

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ public int initFramework(String scriptsFramework,WXParams params) {
@Override
public void takeHeapSnapshot(String filename) {}

@Override
public void clearInstanceCallback(String instanceId){}

@Override
public void reportJSException(String instanceId, String func, String exception) {
if (mJsManager != null) {
Expand Down