From e889227a76ab3fa6a0fc9a75f20f2402fc2e2f96 Mon Sep 17 00:00:00 2001 From: wwwcg Date: Thu, 10 Oct 2024 16:33:04 +0800 Subject: [PATCH 1/2] fix(ios): add nullptr exception protection in rare scenarios (#4055) --- framework/ios/base/executors/HippyJSExecutor.mm | 13 ++++++++----- renderer/native/ios/renderer/HippyUIManager.mm | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/framework/ios/base/executors/HippyJSExecutor.mm b/framework/ios/base/executors/HippyJSExecutor.mm index 2bc0ab487f7..46c787d4cf3 100644 --- a/framework/ios/base/executors/HippyJSExecutor.mm +++ b/framework/ios/base/executors/HippyJSExecutor.mm @@ -661,7 +661,7 @@ - (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block { return; } } - std::shared_ptr engineRsc = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey]; + auto engineRsc = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey]; if (!engineRsc) { return; } @@ -670,8 +670,8 @@ - (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block { auto runner = engine->GetJsTaskRunner(); if (footstone::Worker::IsTaskRunning() && runner == footstone::runner::TaskRunner::GetCurrentTaskRunner()) { block(); - } else { - engine->GetJsTaskRunner()->PostTask(block); + } else if (runner) { + runner->PostTask(block); } } } @@ -683,13 +683,16 @@ - (void)executeAsyncBlockOnJavaScriptQueue:(dispatch_block_t)block { return; } } - std::shared_ptr engineRsc = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey]; + auto engineRsc = [[HippyJSEnginesMapper defaultInstance] JSEngineResourceForKey:self.enginekey]; if (!engineRsc) { return; } auto engine = engineRsc->GetEngine(); if (engine) { - engine->GetJsTaskRunner()->PostTask(block); + auto runner = engine->GetJsTaskRunner(); + if (runner) { + runner->PostTask(block); + } } } diff --git a/renderer/native/ios/renderer/HippyUIManager.mm b/renderer/native/ios/renderer/HippyUIManager.mm index 5cfd1b514aa..b6750e43e87 100644 --- a/renderer/native/ios/renderer/HippyUIManager.mm +++ b/renderer/native/ios/renderer/HippyUIManager.mm @@ -1173,7 +1173,7 @@ - (void)addEventName:(const std::string &)name if (!bridge) { return; } - [bridge.javaScriptExecutor executeBlockOnJavaScriptQueue:^{ + [bridge.javaScriptExecutor executeAsyncBlockOnJavaScriptQueue:^{ auto strongNode = weakNode.lock(); if (strongNode) { strongNode->HandleEvent(event); From 925d1850b1b9efb1ac8873a725d356bf9090dc75 Mon Sep 17 00:00:00 2001 From: wwwcg Date: Fri, 11 Oct 2024 15:57:53 +0800 Subject: [PATCH 2/2] feat(ios): add showScrollIndicator prop for waterfall component (#4057) --- docs/api/hippy-react/components.md | 1 + docs/api/hippy-vue/external-components.md | 1 + .../renderer/component/waterfalllist/HippyWaterfallViewManager.m | 1 + 3 files changed, 3 insertions(+) diff --git a/docs/api/hippy-react/components.md b/docs/api/hippy-react/components.md index 8eb31e2f312..dedb680ed7f 100644 --- a/docs/api/hippy-react/components.md +++ b/docs/api/hippy-react/components.md @@ -550,6 +550,7 @@ import icon from './qb_icon_new.png'; | renderPullHeader | 如何渲染 `PullHeader`,此时 `containPullHeader` 默认设置成 `true` | `() => React.ReactElement` | `Android、iOS、Voltron` | | renderPullFooter | 如何渲染 `PullFooter`,此时 `containPullFooter` 默认设置成 `true` | `() => React.ReactElement` | `Android、iOS、Voltron` | | onScroll | 当触发 `WaterFall` 的滑动事件时回调。`startEdgePos`表示距离 List 顶部边缘滚动偏移量;`endEdgePos`表示距离 List 底部边缘滚动偏移量;`firstVisibleRowIndex`表示当前可见区域内第一个元素的索引;`lastVisibleRowIndex`表示当前可见区域内最后一个元素的索引;`visibleRowFrames`表示当前可见区域内所有 item 的信息(x,y,width,height) | `nativeEvent: { startEdgePos: number, endEdgePos: number, firstVisibleRowIndex: number, lastVisibleRowIndex: number, visibleRowFrames: Object[] }` | `Android、iOS、Voltron` +| showScrollIndicator | 是否显示滚动条。(iOS 3.3.2版本起支持) `default: true` | `boolean` | `iOS` | ## 方法 diff --git a/docs/api/hippy-vue/external-components.md b/docs/api/hippy-vue/external-components.md index 1e47c97ee04..6c6c112713a 100644 --- a/docs/api/hippy-vue/external-components.md +++ b/docs/api/hippy-vue/external-components.md @@ -285,6 +285,7 @@ export default { | containPullFooter | 是否包含 `pull-footer` | `boolean` | `Android、iOS、Voltron` | | numberOfColumns | 瀑布流列数量,Default: 2 | `number` | `Android、iOS、Voltron` | | preloadItemNumber | 滑动到瀑布流底部前提前预加载的 item 数量 | `number` | `Android、iOS、Voltron` | +| showScrollIndicator | 是否显示滚动条。(iOS 3.3.2版本起支持) `default: true` | `boolean` | `iOS` | ## 事件 diff --git a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewManager.m b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewManager.m index 5e3e33f1521..936a8dd5db4 100644 --- a/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewManager.m +++ b/renderer/native/ios/renderer/component/waterfalllist/HippyWaterfallViewManager.m @@ -44,6 +44,7 @@ @implementation HippyWaterfallViewManager HIPPY_EXPORT_VIEW_PROPERTY(containPullFooter, BOOL) HIPPY_EXPORT_VIEW_PROPERTY(scrollEventThrottle, double) HIPPY_EXPORT_VIEW_PROPERTY(onScroll, HippyDirectEventBlock) +HIPPY_REMAP_VIEW_PROPERTY(showScrollIndicator, collectionView.showsVerticalScrollIndicator, BOOL) - (UIView *)view { return [[HippyWaterfallView alloc] init];