qiuxiang / react-native-amap3d

react-native 高德地图组件,使用最新 3D SDK,支持 Android + iOS
https://qiuxiang.github.io/react-native-amap3d/api/
MIT License
1.27k stars 327 forks source link

iOS 海量点崩溃 #784

Open Liu-Ya opened 1 year ago

Liu-Ya commented 1 year ago

看起来是未处理nil的类型错误

Thread 0 name:
Thread 0 Crashed:
0   SCRM                            0x000000010062c524 Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value + 0 (MultiPointManager.swift:0)
1   SCRM                            0x000000010062c524 MultiPoint.getOverlay() + 0 (MultiPointManager.swift:34)
2   SCRM                            0x000000010062c524 protocol witness for Overlay.getOverlay() in conformance MultiPoint + 52 (<compiler-generated>:34)
3   SCRM                            0x00000001006272e8 MapView.didAddSubview(_:) + 84 (MapViewManager.swift:74)
4   SCRM                            0x000000010062747c @objc MapView.didAddSubview(_:) + 52 (<compiler-generated>:0)
5   UIKitCore                       0x000000019650a0ac -[UIView(Internal) _addSubview:positioned:relativeTo:] + 2096 (UIView.m:16913)
6   SCRM                            0x000000010053b40c -[UIView(React) didUpdateReactSubviews] + 148 (UIView+React.m:175)
7   SCRM                            0x0000000100529988 __48-[RCTUIManager _dispatchChildrenDidChangeEvents]_block_invoke + 176 (RCTUIManager.m:1275)
8   SCRM                            0x0000000100529488 __44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke + 164 (RCTUIManager.m:1199)
9   SCRM                            0x0000000100529578 __44-[RCTUIManager flushUIBlocksWithCompletion:]_block_invoke.146 + 28 (RCTUIManager.m:1219)
10  libdispatch.dylib               0x000000019b937460 _dispatch_call_block_and_release + 32 (init.c:1518)
11  libdispatch.dylib               0x000000019b938f88 _dispatch_client_callout + 20 (object.m:560)
12  libdispatch.dylib               0x000000019b9477f4 _dispatch_main_queue_drain + 928 (inline_internal.h:2632)
13  libdispatch.dylib               0x000000019b947444 _dispatch_main_queue_callback_4CF + 44 (queue.c:7917)
14  CoreFoundation                  0x00000001943b16c8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16 (CFRunLoop.c:1780)
15  CoreFoundation                  0x000000019439302c __CFRunLoopRun + 2036 (CFRunLoop.c:3147)
16  CoreFoundation                  0x0000000194397eb0 CFRunLoopRunSpecific + 612 (CFRunLoop.c:3418)
17  GraphicsServices                0x00000001ce58d368 GSEventRunModal + 164 (GSEvent.c:2196)
18  UIKitCore                       0x000000019688d668 -[UIApplication _run] + 888 (UIApplication.m:3758)
19  UIKitCore                       0x000000019688d2cc UIApplicationMain + 340 (UIApplication.m:5348)
20  SCRM                            0x000000010036c63c main + 80 (main.m:7)
21  dyld                            0x00000001b2c90960 start + 2528 (dyldMain.cpp:1170)
Liu-Ya commented 1 year ago
        <MultiPoint
          icon={require("~/assets/images/point.png")}
          items={points}
          onPress={({ nativeEvent }) => onPointClick(nativeEvent.index)}
        />

itemsundefined 时出现上面的错误,设置为[]可以避免崩溃,但更新items无效,不绘制

qiuxiang commented 1 year ago

这个问题我有空再修吧,要避免出错也很简单

{points && <MultiPoint />}

就可以了