diff --git "a/docs/zh-cn/\345\270\270\350\247\201\345\274\200\345\217\221\345\234\272\346\231\257.md" "b/docs/zh-cn/\345\270\270\350\247\201\345\274\200\345\217\221\345\234\272\346\231\257.md" index 8008976b12fccbd29cc747e296e1ea4922a801c9..387acf8780e313771d13084fbcb55ea3f24cfc0b 100644 --- "a/docs/zh-cn/\345\270\270\350\247\201\345\274\200\345\217\221\345\234\272\346\231\257.md" +++ "b/docs/zh-cn/\345\270\270\350\247\201\345\274\200\345\217\221\345\234\272\346\231\257.md" @@ -624,6 +624,42 @@ this.rnInstance.getTurboModule(LogBoxTurboModule.NAME).eventE ![faq-bundlle-hbc](./faqs/figures/faq-bundlle-hbc.png) +> [注意] hbc 只使用于Hermes JS 引擎,JSVM 引擎无法加载hbc。 + +### 由Hermes 引擎切换成 JSVM 引擎 + +目前RNOH默认使用的是Hermes引擎,无需用户额外配置。如果想切换成JSVM 引擎,可遵循以下步骤操作: + +[场景一] 使用RNOH源码har包 + +到应用模块的CMakeLists.txt文件中添加 `set(USE_HERMES 0)`: + +```diff + set(LOG_VERBOSITY_LEVEL 1) ++ set(USE_HERMES 0) +``` + +[场景二] 使用RNOH release版本的har包 + +跟源码类似,不过要改两个地方,具体如下: + +```diff + set(LOG_VERBOSITY_LEVEL 1) ++ set(USE_HERMES 0) + # ... + if("$ENV{RNOH_C_API_ARCH}" STREQUAL "1") + message("Experimental C-API architecture enabled") + target_link_libraries(rnoh PUBLIC libqos.so) + target_compile_definitions(rnoh PUBLIC C_API_ARCH) + endif() + ++ if(USE_HERMES) ++ target_compile_definitions(rnoh PUBLIC USE_HERMES=1) ++ else() ++ target_compile_definitions(rnoh PUBLIC USE_HERMES=0) ++ endif() +``` + ### 如何减少hap包的体积 较大的 HAP 包可能导致应用程序在下载、安装和运行时占用更多资源,影响用户体验。因此,在构建或编译 OpenHarmony 应用程序时,可以通过调整或更改编译设置,以减少最终生成的 HAP 包的文件大小。 diff --git a/tester/harmony/build-profile.template.json5 b/tester/harmony/build-profile.template.json5 index 6120e428edf6d2a83d96f3b2533853a7daddaef9..27046386bc44bedcf2de372331cae78f2dea1cbc 100644 --- a/tester/harmony/build-profile.template.json5 +++ b/tester/harmony/build-profile.template.json5 @@ -6,6 +6,9 @@ signingConfig: 'default', compatibleSdkVersion: '5.0.0(12)', runtimeOS: 'HarmonyOS', + "buildOption": { + "nativeCompiler": "BiSheng" + } }, ], buildModeSet: [ diff --git a/tester/harmony/react_native_openharmony/src/main/ets/RNOH/RNInstancesCoordinator.ets b/tester/harmony/react_native_openharmony/src/main/ets/RNOH/RNInstancesCoordinator.ets index b63dc4ea906520ed6c11d981d933e453a27b45c1..460b7e4a78c48dbe1546e22b559a56b0edb3d9d6 100644 --- a/tester/harmony/react_native_openharmony/src/main/ets/RNOH/RNInstancesCoordinator.ets +++ b/tester/harmony/react_native_openharmony/src/main/ets/RNOH/RNInstancesCoordinator.ets @@ -282,6 +282,9 @@ export class RNInstancesCoordinator { public onDestroy() { const stopTracing = this.logger.clone("onDestroy").startTracing() + if (this.timerId) { + clearTimeout(this.timerId) + } this.jsPackagerClient.onDestroy() this.rnInstanceRegistry.forEach(instance => { instance.onDestroy() @@ -334,7 +337,7 @@ export class RNInstancesCoordinator { }) this.lastChangeTime = currentTime; } else { - if(this.timerId){ + if (this.timerId) { clearTimeout(this.timerId) } this.timerId = setTimeout(() =>{ diff --git a/tester/harmony/react_native_openharmony/src/main/ets/RNSurface.ets b/tester/harmony/react_native_openharmony/src/main/ets/RNSurface.ets index 48e15092faf4923e7969273d6cfcdb4c2c41cc5d..8fa36bdfcd34c61ab05e108c2d3f1ba434411b36 100644 --- a/tester/harmony/react_native_openharmony/src/main/ets/RNSurface.ets +++ b/tester/harmony/react_native_openharmony/src/main/ets/RNSurface.ets @@ -158,6 +158,9 @@ export struct RNSurface { aboutToDisappear() { const surfaceHandle = this.surfaceHandle; + if (this.timerId) { + clearTimeout(this.timerId); + } (async () => { const stopTracing = this.logger.clone("aboutToDisappear").startTracing() this.cleanUpCallbacks.forEach(cb => cb()) @@ -202,6 +205,9 @@ export struct RNSurface { override onMeasureSize(selfLayoutInfo: GeometryInfo, children: Array, constraint: ConstraintSizeOptions): SizeResult { + if (this.surfaceHandle.isDestroyed()) { + return {width: 0, height: 0}; + } const currentTime = Date.now(); if (currentTime - this.lastChangeTime > this.delayTime) { this.currentMeasuredSize = @@ -213,7 +219,7 @@ export struct RNSurface { }) this.lastChangeTime = currentTime; } else { - if(this.timerId){ + if (this.timerId) { clearTimeout(this.timerId) } this.timerId = setTimeout(() =>{