diff --git a/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/LogUtils.java b/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/LogUtils.java index f2fefe3a00f..0f44860a9a9 100644 --- a/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/LogUtils.java +++ b/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/LogUtils.java @@ -27,6 +27,10 @@ public static void enableDebugLog(boolean debuggable) { DEBUG_ENABLE = debuggable; } + public static boolean isDebugMode() { + return DEBUG_ENABLE; + } + public static void d(String tag, String msg) { if (DEBUG_ENABLE) { Log.d(tag, msg); diff --git a/renderer/native/android/src/main/java/com/tencent/renderer/NativeRenderer.java b/renderer/native/android/src/main/java/com/tencent/renderer/NativeRenderer.java index 42c6bec1029..d130efcfefd 100644 --- a/renderer/native/android/src/main/java/com/tencent/renderer/NativeRenderer.java +++ b/renderer/native/android/src/main/java/com/tencent/renderer/NativeRenderer.java @@ -414,8 +414,10 @@ public void dispatchEvent(int rootId, int nodeId, @NonNull String eventName, && !mVirtualNodeManager.checkRegisteredEvent(rootId, nodeId, lowerCaseEventName)) { return; } - LogUtils.d(TAG, "dispatchEvent: id " + nodeId + ", eventName " + eventName - + ", eventType " + eventType + ", params " + params + "\n "); + if (LogUtils.isDebugMode() && !eventName.equals(ChoreographerUtils.DO_FRAME)) { + LogUtils.d(TAG, "dispatchEvent: id " + nodeId + ", eventName " + eventName + + ", eventType " + eventType + ", params " + params + "\n "); + } mRenderProvider.dispatchEvent(rootId, nodeId, lowerCaseEventName, params, useCapture, useBubble); } @@ -497,9 +499,11 @@ public void createNode(final int rootId, @NonNull List nodeList) + nodeIndex + ", className " + className); } final Map props = MapUtils.getMapValue(node, NODE_PROPS); - LogUtils.d(TAG, "createNode: id " + nodeId + ", pid " + nodePid - + ", index " + nodeIndex + ", name " + className + "\n props " + props - + "\n "); + if (LogUtils.isDebugMode()) { + LogUtils.d(TAG, "createNode: id " + nodeId + ", pid " + nodePid + + ", index " + nodeIndex + ", name " + className + "\n props " + props + + "\n "); + } mVirtualNodeManager.createNode(rootId, nodeId, nodePid, nodeIndex, className, props); // If multiple level are nested, the parent is outermost text node. VirtualNode parent = mVirtualNodeManager.checkVirtualParent(rootId, nodeId); @@ -562,9 +566,11 @@ public void updateNode(final int rootId, @NonNull List nodeList) } final Map diffProps = MapUtils.getMapValue(node, NODE_PROPS); final List delProps = MapUtils.getListValue(node, NODE_DELETE_PROPS); - LogUtils.d(TAG, - "updateNode: id " + nodeId + ", diff " + diffProps + ", delete " + delProps - + "\n "); + if (LogUtils.isDebugMode()) { + LogUtils.d(TAG, + "updateNode: id " + nodeId + ", diff " + diffProps + ", delete " + delProps + + "\n "); + } mVirtualNodeManager.updateNode(rootId, nodeId, diffProps, delProps); // If multiple level are nested, the parent is outermost text node. VirtualNode parent = mVirtualNodeManager.checkVirtualParent(rootId, nodeId); @@ -585,7 +591,9 @@ public void updateNode(final int rootId, @NonNull List nodeList) @Override public void deleteNode(final int rootId, @NonNull int[] ids) throws NativeRenderException { final List taskList = new ArrayList<>(ids.length); - LogUtils.d(TAG, "deleteNode " + Arrays.toString(ids) + "\n "); + if (LogUtils.isDebugMode()) { + LogUtils.d(TAG, "deleteNode " + Arrays.toString(ids) + "\n "); + } for (final int nodeId : ids) { // The node id should not be negative number. if (nodeId < 0) { @@ -610,14 +618,18 @@ public void deleteNode(final int rootId, @NonNull int[] ids) throws NativeRender @Override public void moveNode(final int rootId, final int[] ids, final int newPid, final int oldPid, final int insertIndex) throws NativeRenderException { - LogUtils.d(TAG, "moveNode: ids " + Arrays.toString(ids) + ", newPid " + - newPid + ", oldPid " + oldPid + ", insertIndex " + insertIndex + "\n "); + if (LogUtils.isDebugMode()) { + LogUtils.d(TAG, "moveNode: ids " + Arrays.toString(ids) + ", newPid " + + newPid + ", oldPid " + oldPid + ", insertIndex " + insertIndex + "\n "); + } addUITask(() -> mRenderManager.moveNode(rootId, ids, newPid, oldPid, insertIndex)); } @Override public void moveNode(final int rootId, final int pid, @NonNull final List list) { - LogUtils.d(TAG, "moveNode: pid " + pid + ", node list " + list + "\n "); + if (LogUtils.isDebugMode()) { + LogUtils.d(TAG, "moveNode: pid " + pid + ", node list " + list + "\n "); + } VirtualNode parent = mVirtualNodeManager.getVirtualNode(rootId, pid); if (parent == null) { addUITask(() -> mRenderManager.moveNode(rootId, pid, list)); @@ -695,8 +707,10 @@ public void updateEventListener(final int rootId, @NonNull List eventLis throw new NativeRenderException(INVALID_NODE_DATA_ERR, TAG + ": updateEventListener: invalid negative id=" + nodeId); } - LogUtils.d(TAG, - "updateEventListener: id " + nodeId + ", eventProps " + eventProps + "\n "); + if (LogUtils.isDebugMode()) { + LogUtils.d(TAG, + "updateEventListener: id " + nodeId + ", eventProps " + eventProps + "\n "); + } mVirtualNodeManager.updateEventListener(rootId, nodeId, eventProps); taskList.add(() -> mRenderManager.updateEventListener(rootId, nodeId, eventProps)); } @@ -727,9 +741,11 @@ public void callUIFunction(final int rootId, final int nodeId, final long callba throw new NativeRenderException(INVALID_NODE_DATA_ERR, TAG + ": callUIFunction: invalid negative id=" + nodeId); } - LogUtils.d(TAG, - "callUIFunction: id " + nodeId + ", functionName " + functionName + ", params" - + params + "\n "); + if (LogUtils.isDebugMode()) { + LogUtils.d(TAG, + "callUIFunction: id " + nodeId + ", functionName " + functionName + ", params" + + params + "\n "); + } // If callbackId equal to 0 mean this call does not need to callback. final UIPromise promise = (callbackId == 0) ? null : new UIPromise(callbackId, functionName, rootId, nodeId, @@ -749,7 +765,9 @@ public void doPromiseCallBack(int result, long callbackId, @NonNull String funct @Override public void endBatch(final int rootId) throws NativeRenderException { - LogUtils.d(TAG, "=============================endBatch " + rootId); + if (LogUtils.isDebugMode()) { + LogUtils.d(TAG, "=============================endBatch " + rootId); + } Map layoutToUpdate = mVirtualNodeManager.endBatch(rootId); if (layoutToUpdate != null) { for (Entry entry : layoutToUpdate.entrySet()) {