From 82eaecf25bd2fd14b09fd108335bc5a88139719d Mon Sep 17 00:00:00 2001 From: maxli Date: Tue, 8 Oct 2024 10:39:56 +0800 Subject: [PATCH] fix(android): recordNativeInitEndTime after initJSBridge --- .../java/com/tencent/mtt/hippy/HippyEngineManagerImpl.java | 3 +-- .../com/tencent/mtt/hippy/bridge/HippyBridgeManagerImpl.java | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/framework/android/src/main/java/com/tencent/mtt/hippy/HippyEngineManagerImpl.java b/framework/android/src/main/java/com/tencent/mtt/hippy/HippyEngineManagerImpl.java index 5eea31752ab..393e29fee7e 100644 --- a/framework/android/src/main/java/com/tencent/mtt/hippy/HippyEngineManagerImpl.java +++ b/framework/android/src/main/java/com/tencent/mtt/hippy/HippyEngineManagerImpl.java @@ -689,7 +689,6 @@ void notifyEngineInitialized(final EngineInitStatus statusCode, final Throwable } private void onEngineInitialized(EngineInitStatus statusCode, Throwable error) { - mEngineContext.getJsDriver().recordNativeInitEndTime(mInitStartTime, System.currentTimeMillis()); mGlobalConfigs.getEngineMonitorAdapter().onEngineInitialized(statusCode); for (EngineListener listener : mEventListeners) { listener.onInitialized(statusCode, error == null ? null : error.toString()); @@ -879,7 +878,7 @@ public HippyEngineContextImpl(@Nullable DomManager domManager) throws RuntimeExc mJsDriver = new JsDriver(); mBridgeManager = new HippyBridgeManagerImpl(this, mCoreBundleLoader, getBridgeType(), enableV8Serialization, mDebugMode, - mServerHost, mGroupId, mThirdPartyAdapter, v8InitParams, mJsDriver); + mServerHost, mGroupId, mThirdPartyAdapter, v8InitParams, mJsDriver, mInitStartTime); mDomManager = (domManager != null) ? domManager : new DomManager(mGroupId); mRenderer = createRenderer(RenderConnector.NATIVE_RENDERER); mDomManager.attachToRenderer(mRenderer); diff --git a/framework/android/src/main/java/com/tencent/mtt/hippy/bridge/HippyBridgeManagerImpl.java b/framework/android/src/main/java/com/tencent/mtt/hippy/bridge/HippyBridgeManagerImpl.java index ab830ac3b00..182f3fb27ae 100644 --- a/framework/android/src/main/java/com/tencent/mtt/hippy/bridge/HippyBridgeManagerImpl.java +++ b/framework/android/src/main/java/com/tencent/mtt/hippy/bridge/HippyBridgeManagerImpl.java @@ -99,6 +99,7 @@ public enum BridgeState { final boolean mEnableV8Serialization; ArrayList mLoadedBundleInfo = null; private final int mGroupId; + private long mInitStartTime = 0; private final HippyThirdPartyAdapter mThirdPartyAdapter; private StringBuilder mStringBuilder; private SafeHeapWriter safeHeapWriter; @@ -111,10 +112,11 @@ public enum BridgeState { public HippyBridgeManagerImpl(HippyEngineContext context, HippyBundleLoader coreBundleLoader, int bridgeType, boolean enableV8Serialization, boolean isDevModule, String debugServerHost, int groupId, HippyThirdPartyAdapter thirdPartyAdapter, - V8InitParams v8InitParams, @NonNull JsDriver jsDriver) { + V8InitParams v8InitParams, @NonNull JsDriver jsDriver, long initStartTime) { mContext = context; mCoreBundleLoader = coreBundleLoader; mGroupId = groupId; + mInitStartTime = initStartTime; mThirdPartyAdapter = thirdPartyAdapter; mEnableV8Serialization = enableV8Serialization; mHippyBridge = new HippyBridgeImpl(context, this, bridgeType == BRIDGE_TYPE_SINGLE_THREAD, @@ -257,6 +259,7 @@ public void Call(long result, Message message, String action, if (mThirdPartyAdapter != null) { mThirdPartyAdapter.onRuntimeInit(runtimeId); } + mContext.getJsDriver().recordNativeInitEndTime(mInitStartTime, System.currentTimeMillis()); if (mCoreBundleLoader != null) { timeMonitor.addPoint(TimeMonitor.MONITOR_GROUP_INIT_ENGINE, TimeMonitor.MONITOR_POINT_LOAD_VENDOR_JS);