From 1672efe54a7a1b809e89ce803025406d03ef83f5 Mon Sep 17 00:00:00 2001 From: maxli Date: Fri, 8 Nov 2024 11:11:19 +0800 Subject: [PATCH 1/4] fix(android): update pull header LayoutParams in updateLayout --- .../HippyPullHeaderViewController.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/refresh/HippyPullHeaderViewController.java b/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/refresh/HippyPullHeaderViewController.java index 886cc3394d1..d07422fffb9 100644 --- a/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/refresh/HippyPullHeaderViewController.java +++ b/renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/refresh/HippyPullHeaderViewController.java @@ -27,6 +27,7 @@ import com.tencent.mtt.hippy.annotation.HippyController; import com.tencent.mtt.hippy.common.HippyArray; import com.tencent.mtt.hippy.uimanager.ControllerManager; +import com.tencent.mtt.hippy.uimanager.ControllerRegistry; import com.tencent.mtt.hippy.uimanager.HippyViewController; import com.tencent.renderer.node.PullHeaderRenderNode; import com.tencent.renderer.node.RenderNode; @@ -102,6 +103,26 @@ public void run() { } } + + @Override + public void updateLayout(int rootId, int id, int x, int y, int width, int height, + ControllerRegistry componentHolder) { + super.updateLayout(rootId, id, x, y, width, height, componentHolder); + View view = componentHolder.getView(rootId, id); + if (view instanceof HippyPullHeaderView && view.getParent() instanceof ViewGroup) { + int w = view.getWidth(); + int h = view.getHeight(); + ViewGroup.LayoutParams lp = view.getLayoutParams(); + if (lp != null) { + LogUtils.d(TAG, "updateLayout: id " + id + ", w " + w + ", h " + h + + ", width " + width + ", height " + height + ", lp.width " + lp.width + ", lp.height " + + lp.height); + lp.width = width; + lp.height = height; + } + } + } + @Override public void dispatchFunction(@NonNull HippyPullHeaderView pullHeaderView, @NonNull String functionName, @NonNull HippyArray params) { From a668d5266a7024a7b15f982eea36e2bcd997712d Mon Sep 17 00:00:00 2001 From: maxli Date: Fri, 8 Nov 2024 11:29:48 +0800 Subject: [PATCH 2/4] fix(android): avoiding code optimization issues for R8 compile --- modules/android/serialization/build.gradle | 1 + .../hippy/serialization/nio/writer/SafeHeapWriter.java | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/android/serialization/build.gradle b/modules/android/serialization/build.gradle index b82c85d85ff..b1dc05b618c 100644 --- a/modules/android/serialization/build.gradle +++ b/modules/android/serialization/build.gradle @@ -32,4 +32,5 @@ android { dependencies { implementation deps.annotation + implementation project(':hippy-support') } \ No newline at end of file diff --git a/modules/android/serialization/src/main/java/com/tencent/mtt/hippy/serialization/nio/writer/SafeHeapWriter.java b/modules/android/serialization/src/main/java/com/tencent/mtt/hippy/serialization/nio/writer/SafeHeapWriter.java index ebd4f5fb078..b30b18a7237 100644 --- a/modules/android/serialization/src/main/java/com/tencent/mtt/hippy/serialization/nio/writer/SafeHeapWriter.java +++ b/modules/android/serialization/src/main/java/com/tencent/mtt/hippy/serialization/nio/writer/SafeHeapWriter.java @@ -15,6 +15,7 @@ */ package com.tencent.mtt.hippy.serialization.nio.writer; +import com.tencent.mtt.hippy.utils.LogUtils; import java.nio.ByteBuffer; @SuppressWarnings({"unused"}) @@ -73,22 +74,29 @@ public void putDouble(double d) { } @SuppressWarnings("SpellCheckingInspection") + // After upgrading to AGP version 8 or above, R8 compilation will be started. Due to the optimization + // of R8 compilation code, it will affect the logic of the code here, causing encoding and decoding + // failures and white screen problems. Therefore, it is necessary to add some logs in the implementation + // of this function to avoid R8 compilation optimization. @Override public int putVarint(long l) { if (count + 10 > value.length) { enlargeBuffer(count + 10); } - + LogUtils.d("CallFunction", "putVarint l " + l + ", count " + count); long rest = l; int bytes = 0; byte b; do { b = (byte) rest; + LogUtils.d("CallFunction", "putVarint origin b " + b + ", count " + count); b |= 0x80; + LogUtils.d("CallFunction", "putVarint b " + Byte.toUnsignedInt(b) + ", count " + count); value[count++] = b; rest >>>= 7; bytes++; } while (rest != 0); + LogUtils.d("CallFunction", "putVarint bb " + Byte.toUnsignedInt((byte) (b & 0x7f)) + ", bytes " + bytes + ", count " + count); value[count - 1] = (byte) (b & 0x7f); return bytes; } From a7b03f322c71708f613858cda73b5644cf29d40d Mon Sep 17 00:00:00 2001 From: maxli Date: Fri, 8 Nov 2024 15:19:33 +0800 Subject: [PATCH 3/4] fix(android): correct some log level --- framework/android/connector/dom/src/main/cpp/src/dom_jni.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/framework/android/connector/dom/src/main/cpp/src/dom_jni.cc b/framework/android/connector/dom/src/main/cpp/src/dom_jni.cc index 0c5021a3b47..750eeeaf0f2 100644 --- a/framework/android/connector/dom/src/main/cpp/src/dom_jni.cc +++ b/framework/android/connector/dom/src/main/cpp/src/dom_jni.cc @@ -163,18 +163,16 @@ jint CreateDomManager(JNIEnv* j_env, jobject j_obj, jint j_group_id, jint j_shar if (share_dom_id > 0) { flag = hippy::global_data_holder.Find(static_cast(share_dom_id), share_dom_manager); } - FOOTSTONE_DLOG(ERROR) << "CreateDomManager flag " << flag << ", dom_id " << dom_id << ", share_dom_id " << share_dom_id; + FOOTSTONE_DLOG(INFO) << "CreateDomManager flag " << flag << ", dom_id " << dom_id<< ", share_dom_id " << share_dom_id << ", group_id " << group_id; if (flag && group_id != kDefaultGroupId) { - FOOTSTONE_DLOG(ERROR) << "CreateDomManager share "; auto dom_manager_object = std::any_cast>(share_dom_manager); auto worker = dom_manager_object->GetWorker(); auto runner = dom_manager_object->GetTaskRunner(); dom_manager->SetTaskRunner(runner); dom_manager->SetWorker(worker); auto count = worker->FetchAndAddReuseCount(); - FOOTSTONE_DLOG(ERROR) << "CreateDomManager worker reuse count " << count << ", dom manager id " << dom_id; + FOOTSTONE_DLOG(INFO) << "CreateDomManager worker reuse count " << count << ", dom manager id " << dom_id; } else { - FOOTSTONE_DLOG(ERROR) << "CreateDomManager create new "; auto worker = std::make_shared(kDomWorkerName, false); auto callback = std::make_shared(j_env, j_obj); worker->BeforeStart([callback]() { From 09c1de860ece93d55aa878fc0fa5e1b54525374c Mon Sep 17 00:00:00 2001 From: maxli Date: Fri, 8 Nov 2024 16:04:36 +0800 Subject: [PATCH 4/4] fix(android): only debug call R8 avoiding log --- .../nio/writer/SafeHeapWriter.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/android/serialization/src/main/java/com/tencent/mtt/hippy/serialization/nio/writer/SafeHeapWriter.java b/modules/android/serialization/src/main/java/com/tencent/mtt/hippy/serialization/nio/writer/SafeHeapWriter.java index b30b18a7237..7d08fe8b402 100644 --- a/modules/android/serialization/src/main/java/com/tencent/mtt/hippy/serialization/nio/writer/SafeHeapWriter.java +++ b/modules/android/serialization/src/main/java/com/tencent/mtt/hippy/serialization/nio/writer/SafeHeapWriter.java @@ -83,20 +83,29 @@ public int putVarint(long l) { if (count + 10 > value.length) { enlargeBuffer(count + 10); } - LogUtils.d("CallFunction", "putVarint l " + l + ", count " + count); + if (LogUtils.isDebugMode()) { + LogUtils.d("CallFunction", "putVarint l " + l + ", count " + count); + } long rest = l; int bytes = 0; byte b; do { b = (byte) rest; - LogUtils.d("CallFunction", "putVarint origin b " + b + ", count " + count); + if (LogUtils.isDebugMode()) { + LogUtils.d("CallFunction", "putVarint origin b " + b + ", count " + count); + } b |= 0x80; - LogUtils.d("CallFunction", "putVarint b " + Byte.toUnsignedInt(b) + ", count " + count); + if (LogUtils.isDebugMode()) { + LogUtils.d("CallFunction", "putVarint b " + Byte.toUnsignedInt(b) + ", count " + count); + } value[count++] = b; rest >>>= 7; bytes++; } while (rest != 0); - LogUtils.d("CallFunction", "putVarint bb " + Byte.toUnsignedInt((byte) (b & 0x7f)) + ", bytes " + bytes + ", count " + count); + if (LogUtils.isDebugMode()) { + LogUtils.d("CallFunction", + "putVarint bb " + Byte.toUnsignedInt((byte) (b & 0x7f)) + ", bytes " + bytes + ", count " + count); + } value[count - 1] = (byte) (b & 0x7f); return bytes; }