diff --git a/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/TimeMonitor.java b/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/TimeMonitor.java index ab0a338b10a..fa3673120dc 100644 --- a/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/TimeMonitor.java +++ b/modules/android/hippy_support/src/main/java/com/tencent/mtt/hippy/utils/TimeMonitor.java @@ -157,9 +157,9 @@ void end() { void print() { if (mMonitorPoints != null) { - LogUtils.i(TAG, "group " + name + ", totalTime " + totalTime + "ms"); + LogUtils.e(TAG, "group " + name + ", totalTime " + totalTime + "ms"); for (MonitorPoint monitorPoint : mMonitorPoints) { - LogUtils.i(TAG, + LogUtils.e(TAG, monitorPoint.key + ": " + (monitorPoint.endTime - monitorPoint.startTime) + "ms"); } diff --git a/renderer/native/android/src/main/java/com/tencent/mtt/hippy/HippyRootView.java b/renderer/native/android/src/main/java/com/tencent/mtt/hippy/HippyRootView.java index 23a1cb21eff..585aa321c64 100644 --- a/renderer/native/android/src/main/java/com/tencent/mtt/hippy/HippyRootView.java +++ b/renderer/native/android/src/main/java/com/tencent/mtt/hippy/HippyRootView.java @@ -34,6 +34,7 @@ import com.tencent.renderer.NativeRenderContext; import com.tencent.renderer.NativeRendererManager; +import java.lang.ref.WeakReference; import java.util.Map; import static android.content.res.Configuration.ORIENTATION_UNDEFINED; @@ -116,7 +117,7 @@ protected void onDetachedFromWindow() { private GlobalLayoutListener getGlobalLayoutListener() { if (mGlobalLayoutListener == null) { - mGlobalLayoutListener = new GlobalLayoutListener(); + mGlobalLayoutListener = new GlobalLayoutListener(this); } return mGlobalLayoutListener; } @@ -124,6 +125,11 @@ private GlobalLayoutListener getGlobalLayoutListener() { private class GlobalLayoutListener implements ViewTreeObserver.OnGlobalLayoutListener { private int mOrientation = ORIENTATION_UNDEFINED; + private final WeakReference mRootViewRef; + + GlobalLayoutListener(View rootView) { + mRootViewRef = new WeakReference<>(rootView); + } @Override public void onGlobalLayout() { @@ -137,7 +143,10 @@ public void onGlobalLayout() { sendOrientationChangeEvent(mOrientation); NativeRender nativeRenderer = NativeRendererManager.getNativeRenderer(context); if (nativeRenderer != null) { - nativeRenderer.updateDimension(-1, -1); + View rootView = mRootViewRef.get(); + int width = (rootView != null) ? rootView.getWidth() : -1; + int height = (rootView != null) ? rootView.getHeight() : -1; + nativeRenderer.updateDimension(width, height); } } }