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

Commit

Permalink
Feature/new log branch (#2768)
Browse files Browse the repository at this point in the history
* Add TimeCalculator

* Fix All Log Problem

* Add for cal initJsc

* Add Tlog Type

* Refine log Utils

* add jni setLogType

to Make weexcore and jss know log type

* add Debug & perf flag for log utils

* Add logType interface

* add setLogLevel interface

* add  Tlog level

* Log Api jss <-> weexcore Done

* performance Log api Done

* Scan to set log level dynamicly

* All Log Api is fine

* Only Add time calculator in performance mode

* Refine Log Print logic

* Support all cpu type

* Add For test

* Fix jni type

* modify for ios

* Add CreateInstance tlog

* remove debug log

* Do nothing for performance

* clear  unuse log

* Support "wx" in  Transform.translate

* remove useless log

*  [Android] record performance detail cost (#2769)

* [iOS] fix multi jsthread error

* [Android] Avoid duplicated call of setViewPort (#2764)

* [iOS] Protect animation argument missing which cause crash on iOS. (#2771)

* [iOS] fix compile error

* Remove Useles log
  • Loading branch information
Darin726 authored and lucky-chen committed Aug 1, 2019
1 parent 7b51a1d commit 10ddece
Show file tree
Hide file tree
Showing 79 changed files with 3,164 additions and 2,135 deletions.
8 changes: 4 additions & 4 deletions android/sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ task checkNdkVersion() {
ndkDir = properties.getProperty('ndk.dir')
}

if(null == ndkDir){
def errMsg ='please set ndk.dir path in project/local.properties and ndk-16 supported only,example: ndk.dir=/Users/xxx/Library/Android/sdk/ndk-bundle-r16'
throw new StopActionException(errMsg)
}
// if(null == ndkDir){
// def errMsg ='please set ndk.dir path in project/local.properties and ndk-16 supported only,example: ndk.dir=/Users/xxx/Library/Android/sdk/ndk-bundle-r16'
// throw new StopActionException(errMsg)
// }
}

preBuild.dependsOn checkNdkVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public class WXEnvironment {

public static LogLevel sLogLevel = LogLevel.DEBUG;
private static boolean isApkDebug = true;
public static boolean isPerf = true;
public static boolean isPerf = false;
private static boolean sDebugFlagInit = false;

private static boolean openDebugLog = true;
Expand Down
12 changes: 11 additions & 1 deletion android/sdk/src/main/java/com/taobao/weex/WXHttpListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.taobao.weex.performance.WXInstanceApm;
import com.taobao.weex.tracing.WXTracing;
import com.taobao.weex.utils.WXLogUtils;
import com.taobao.weex.utils.tools.LogDetail;

import java.util.HashMap;
import java.util.List;
Expand All @@ -54,10 +55,14 @@ public class WXHttpListener implements IWXHttpAdapter.OnHttpListener {
private boolean isInstanceReady =false;
private boolean isResponseHasWait = false;
private WXResponse mResponse;
private LogDetail mLogDetail;

private String mBundleUrl;

public WXHttpListener(WXSDKInstance instance) {
if(instance != null) {
mLogDetail = instance.mTimeCalculator.createLogDetail("downloadBundleJS");
}
this.instance = instance;
this.traceId = WXTracing.nextId();
this.mWXPerformance = instance.getWXPerformance();
Expand Down Expand Up @@ -102,6 +107,9 @@ public void onHttpStart() {
if (this.instance != null
&& this.instance.getWXStatisticsListener() != null) {
this.instance.getWXStatisticsListener().onHttpStart();
if(mLogDetail != null) {
mLogDetail.taskStart();
}
}
}

Expand Down Expand Up @@ -131,7 +139,9 @@ public void onHttpResponseProgress(int loadedLength) {

@Override
public void onHttpFinish(WXResponse response) {

if(mLogDetail != null) {
mLogDetail.taskEnd();
}
if (this.instance != null
&& this.instance.getWXStatisticsListener() != null) {
this.instance.getWXStatisticsListener().onHttpFinish();
Expand Down
4 changes: 2 additions & 2 deletions android/sdk/src/main/java/com/taobao/weex/WXSDKEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private static void doInitInternal(final Application application,final InitConfi
}
WXEnvironment.JsFrameworkInit = false;

WXBridgeManager.getInstance().post(new Runnable() {
WXBridgeManager.getInstance().postWithName(new Runnable() {
@Override
public void run() {
long start = System.currentTimeMillis();
Expand Down Expand Up @@ -243,7 +243,7 @@ public void run() {
WXEnvironment.sSDKInitExecuteTime = System.currentTimeMillis() - start;
WXLogUtils.renderPerformanceLog("SDKInitExecuteTime", WXEnvironment.sSDKInitExecuteTime);
}
});
},null,"doInitWeexSdkInternal");
WXStateRecord.getInstance().startJSThreadWatchDog();
register();
}
Expand Down
16 changes: 14 additions & 2 deletions android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
import com.taobao.weex.utils.WXUtils;
import com.taobao.weex.utils.WXViewUtils;
import com.taobao.weex.utils.cache.RegisterCache;
import com.taobao.weex.utils.tools.LogDetail;
import com.taobao.weex.utils.tools.TimeCalculator;
import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
Expand Down Expand Up @@ -205,6 +207,7 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan

private String mRenderType = RenderTypes.RENDER_TYPE_NATIVE;

public TimeCalculator mTimeCalculator;
/**
* Default Width And Viewport is 750,
* when screen width change, we adjust viewport to adapter screen change
Expand Down Expand Up @@ -581,6 +584,8 @@ public void init(Context context) {

// WXBridgeManager.getInstance().checkJsEngineMultiThread();
mDisableSkipFrameworkInit = isDisableSkipFrameworkInDataRender();

mTimeCalculator = new TimeCalculator(this);
}

/**
Expand Down Expand Up @@ -814,6 +819,7 @@ private void renderInternal(String pageName,
return;
}

LogDetail logDetail = mTimeCalculator.createLogDetail("renderInternal");
mRenderStrategy = flag;

//some case ,from render(template),but not render (url)
Expand Down Expand Up @@ -852,7 +858,7 @@ private void renderInternal(String pageName,
return;
}


TimeCalculator timeCalculator = new TimeCalculator(this);

mWXPerformance.JSTemplateSize = template.length() / 1024f;
mApmForInstance.addStats(WXInstanceApm.KEY_PAGE_STATS_BUNDLE_SIZE,mWXPerformance.JSTemplateSize);
Expand Down Expand Up @@ -880,12 +886,14 @@ private void renderInternal(String pageName,
WXViewUtils.getScreenDensity(mContext));
}
}
logDetail.taskStart();
if (isPreInitMode()){
getApmForInstance().onStage(WXInstanceApm.KEY_PAGE_STAGES_LOAD_BUNDLE_START);
WXBridgeManager.getInstance().loadJsBundleInPreInitMode(getInstanceId(),template.getContent());
} else {
WXSDKManager.getInstance().createInstance(this, template, renderOptions, jsonInitData);
}
logDetail.taskEnd();
mRendered = true;

final IWXJscProcessManager wxJscProcessManager = WXSDKManager.getInstance().getWXJscProcessManager();
Expand Down Expand Up @@ -957,6 +965,9 @@ private void renderByUrlInternal(String pageName,
final String jsonInitData,
WXRenderStrategy flag) {


LogDetail logDetail = mTimeCalculator.createLogDetail("renderByUrlInternal");
logDetail.taskStart();
ensureRenderArchor();
pageName = wrapPageName(pageName, url);
mBundleUrl = url;
Expand Down Expand Up @@ -1018,6 +1029,7 @@ private void renderByUrlInternal(String pageName,
mHttpListener.setSDKInstance(this);
mApmForInstance.onStage(WXInstanceApm.KEY_PAGE_STAGES_DOWN_BUNDLE_START);
adapter.sendRequest(wxRequest, (IWXHttpAdapter.OnHttpListener) mHttpListener);
logDetail.taskEnd();
}

private WXHttpListener mHttpListener = null;
Expand Down Expand Up @@ -1436,7 +1448,7 @@ public void onActivityDestroy() {
WXLogUtils.w("Warning :Component tree has not build completely, onActivityDestroy can not be call!");
}
}

this.mTimeCalculator.println();
destroy();
}

Expand Down
11 changes: 10 additions & 1 deletion android/sdk/src/main/java/com/taobao/weex/bridge/WXBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.taobao.weex.utils.WXLogUtils;
import com.taobao.weex.utils.WXUtils;
import com.taobao.weex.utils.WXWsonJSONSwitch;
import com.taobao.weex.utils.tools.TimeCalculator;

import java.io.Serializable;
import java.util.HashMap;
Expand All @@ -51,7 +52,7 @@
* Communication interface for Java code and JavaScript code.
*/

public class WXBridge implements IWXBridge {
public class WXBridge implements IWXBridge {

private native int nativeInitFrameworkEnv(String framework, WXParams params, String cacheDir, boolean pieSupport);

Expand Down Expand Up @@ -136,6 +137,7 @@ public class WXBridge implements IWXBridge {
public native void nativeUpdateGlobalConfig(String config);

private native void nativeSetViewPortWidth(String instanceId, float viewPortWidth);
private native void nativeSetLogType(float type, float isPerf);

public static final boolean MULTIPROCESS = true;

Expand All @@ -146,6 +148,12 @@ public void updateInitFrameworkParams(String key, String value, String desc){
nativeUpdateInitFrameworkParams(key, value, desc);
}

@Override
public void setLogType(float type, boolean isPerf) {
Log.e("WeexCore", "setLog" + WXEnvironment.sLogLevel.getValue() + "isPerf : " + isPerf);
nativeSetLogType(type, isPerf ? 1 : 0);
}

@Override
public int initFramework(String framework, WXParams params) {
return nativeInitFramework(framework, params);
Expand Down Expand Up @@ -220,6 +228,7 @@ public void takeHeapSnapshot(String filename) {

@Override
public int createInstanceContext(String instanceId, String name, String function, WXJSObject[] args) {
Log.e(TimeCalculator.TIMELINE_TAG,"createInstance :" + System.currentTimeMillis());
WXStateRecord.getInstance().recordAction(instanceId,"createInstanceContext:");
return nativeCreateInstanceContext(instanceId, name, function, args);
}
Expand Down
Loading

0 comments on commit 10ddece

Please sign in to comment.