note11g / flutter_naver_map

Naver Mobile Dynamic Map SDK for Flutter (unofficial)
BSD 3-Clause "New" or "Revised" License
143 stars 69 forks source link

[iOS] 네이버맵 진입 시 OverlayImage 관련 비정상 종료 이슈 #280

Open jhlee-danbi opened 13 hours ago

jhlee-danbi commented 13 hours ago

안녕하세요. Flutter Naver Map 잘 사용하고 있습니다. 정말 감사합니다 :)

아이폰에서 앱을 처음 열고나서 네이버맵 화면으로 진입하면 간혹 비정상 종료 이슈가 있어 제보드렸습니다. (10번 중 서너 번 정도 발생하는 것 같아요)

Plugin Version: 1.3.0+1 Flutter Version: 3.24.3

아래는 Firebase Crashlytics 로 기록된 비정상 종료 로그입니다.

스크린샷 2024-11-23 오후 8 17 23
Crashed: com.apple.main-thread
0  flutter_naver_map              0x245dc $s17flutter_naver_map13NOverlayImageV011makeOverlayE13WithAssetPath33_79A6886F01FC04EFFEE84731833F36F5LLSo010NMFOverlayE0CyF + 692
1  flutter_naver_map              0x21228 $s17flutter_naver_map7NMarkerV17applyAtRawOverlayySo9NMFMarkerCAFFTf4nn_g + 468
2  flutter_naver_map              0x1fe44 $s17flutter_naver_map7NMarkerVAA20LazyOrAddableOverlayA2aDP09createMapH00H4TypeQzyFTW + 124
3  flutter_naver_map              0x397c4 $s17flutter_naver_map14OverlayHandlerPAAE04saveD11WithAddable7creator07createdD0So10NMFOverlayCqd___0D4TypeQyd__SgtAA0hD0Rd__lF + 228
4  flutter_naver_map              0x14c90 $s17flutter_naver_map18NaverMapControllerC020saveAddableOverlayAtiF007addableI0yx_tAA0hI0RzlF + 96
5  flutter_naver_map              0x1464c $s17flutter_naver_map18NaverMapControllerC13addOverlayAll11rawOverlays9onSuccessySaySDySSypGG_yypSgctF + 128
6  flutter_naver_map              0x13620 $s17flutter_naver_map22NaverMapControlHandlerPAAE6handle4call6resultySo17FlutterMethodCallC_yypSgctFAA0dE10ControllerC_Tg5 + 6608
7  flutter_naver_map              0x13fa4 $s17flutter_naver_map18NaverMapControllerC0bE07channel07overlayF0ACSo08NMFNaverE4ViewCSg_So20FlutterMethodChannelCAA14OverlayHandler_ptcfcySo0kL4CallC_yypSgctcACcfu1_yAN_yAOctcfu2_ + 20
8  flutter_naver_map              0x18bc0 $sSo17FlutterMethodCallCypSgIegn_Ieggg_AByXlSgIeyBy_IeyByy_TR + 104
9  Flutter                        0x5d4b50 InternalFlutterGpu_Texture_AsImage + 5077068
10 Flutter                        0x5f2e8 (누락 UUID 4c4c440955553144a19ab64ea953a1e7)
11 libdispatch.dylib              0x26a8 <redacted> + 32
12 libdispatch.dylib              0x4300 <redacted> + 20
13 libdispatch.dylib              0x12998 <redacted> + 984
14 libdispatch.dylib              0x125b0 _dispatch_main_queue_callback_4CF + 44
15 CoreFoundation                 0x36f9c <redacted> + 16
16 CoreFoundation                 0x33ca8 <redacted> + 1996
17 CoreFoundation                 0x333f8 CFRunLoopRunSpecific + 608
18 GraphicsServices               0x34f8 GSEventRunModal + 164
19 UIKitCore                      0x22c8a0 <redacted> + 888
20 UIKitCore                      0x22bedc UIApplicationMain + 340
21 UIKitCore                      0x456598 <redacted> + 12220
22 Runner                         0xcb50 main + 4374514512 (AppDelegate.swift:4374514512)
23 ???                            0x1cd7d6dcc (누락)

아래와 같이 코드를 작성했습니다. WidgetsBinding.instance.addPostFrameCallback 에서 api 를 호출해서 지정된 장소에 마커를 그리는 방식입니다.

Future<void> _setMarker() async {
  try {
    // 오버레이 초기화
    mapController?.clearOverlays();

    // api 호출 -> 마커 생성
    final marker = NMarker(
      id: 'marker-id', 
      position: NLatLng(
        latitude, 
        longitude, 
      ),
      icon: NOverlayImage.fromAssetImage('images/store.png'), 
    );

    // 탭 리스너 추가
    marker.setOnTapListener((NMarker tappedMarker) async {
      print('Marker ${tappedMarker.id} tapped');
    });

    // 오버레이 추가
    mapController?.addOverlayAll({marker});
  } catch (e, stacktrace) {
    print(stacktrace);
  }
}

 @override
  void initState() {
    super.initState();
     WidgetsBinding.instance.addPostFrameCallback((_) async {
      await _setMarker();
    });
  }
// 네이버맵
NaverMap(
  options: NaverMapViewOptions(
    logoAlign: NLogoAlign.rightBottom,
    initialCameraPosition: NCameraPosition(
      target: NLatLng(widget.latitude, widget.longitude),
      zoom: 16,
    ),
  ),
  forceGesture: false,
  onMapReady: (controller) async {
    if (!mounted) return;

    mapController = controller;
    mapController?.setLocationTrackingMode(NLocationTrackingMode.follow);
  },
);

어디가 문제인지 알 수 있을까요? 확인해주시면 감사하겠습니다!