Unact / yandex_mapkit

Flutter implementation of YandexMapkit
MIT License
132 stars 151 forks source link

IOS: NSInternalInconsistencyException Attempt to set invalid focusRect: rect.topLeft is out of screen #328

Closed Ravensof closed 5 months ago

Ravensof commented 8 months ago

Привет, есть странные краши на айос

в конструкторе виджета YandexMap есть колбэк onMapCreated, в который возвращается YandexMapController. и если сразу попробовать вызвать controller.moveCamera(), то на айос это с высокой вероятностью вызывает краши.

если перед вызовом controller.moveCamera() добавить задержку в одну секунду, то краши прекращаются, но это какой-то костыль. это баг, фича или я что-то делаю не так?

NSInternalInconsistencyException
Attempt to set invalid focusRect: rect.topLeft is out of screen; rect.bottomRight is out of screen; Exception stack trace (top 20 entries): 
# 0: 13776400 /private/var/containers/Bundle/Application/17AFE5C2-977F-42C8-81A5-476547688578/Runner.app/Runner _yandex_impl___ZN4asio6detail16service_registry6createINS0_14kqueue_reactorENS_17execution_contextEEEPNS4_7serviceEPv 
# 1: 13804792 /private/var/containers/Bundle/Application/17AFE5C2-977F-42C8-81A5-476547688578/Runner.app/Runner _yandex_impl___ZN4asio6detail16service_registry6createINS0_14kqueue_reactorENS_17execution_contextEEEPNS4_7serviceEPv 
# 2: 13798464 /private/var/containers/Bundle/Application/17AFE5C2-977F-42C8-81A5-476547688578/Runner.app/Runner _yandex_impl___ZN4asio6detail16service_registry6createINS0_14kqueue_reactorENS_17execution_contextEEEPNS4_7serviceEPv 
# 3: 13798024 /private/var/containers/Bundle/Application/17AFE5C2-977F-42C8-81A5-476547688578/Runner.app/Runner _yandex_impl___ZN4asio6detail16service_registry6createINS0_14kqueue_reactorENS_17execution_contextEEEPNS4_7serviceEPv 
# 4: 13801188 /private/var/containers/Bundle/Application/17AFE5C2-977F-42C8-81A5-476547688578/Runner.app/Runner _yandex_impl___ZN4asio6detail16service_registry6createINS0_14kqueue_reactorENS_17execution_contextEEEPNS4_7serviceEPv 
# 5: 24116732 /private/var/containers/Bundle/Application/17AFE5C2-977F-42C8-81A5-476547688578/Runner.app/Runner _yandex_impl___ZN4asio6detail16service_registry6createINS0_27reactive_descriptor_serviceENS_10io_contextEEEPNS_17execution_context7serviceEPv 
# 6: 24115036 /private/var/containers/Bundle/Application/17AFE5C2-977F-42C8-81A5-476547688578/Runner.app/Runner _yandex_impl___ZN4asio6detail16service_registry6createINS0_27reactive_descriptor_serviceENS_10io_contextEEEPNS_17execution_context7serviceEPv 
# 7: 24114812 /private/var/containers/Bundle/Application/17AFE5C2-977F-42C8-81A5-476547688578/Runner.app/Runner _yandex_impl___ZN4asio6detail16service_registry6createINS0_27reactive_descriptor_serviceENS_10io_contextEEEPNS_1
  @override
  Widget build(BuildContext context) => YandexMap(
        gestureRecognizers: const {
          Factory<PanGestureRecognizer>(PanGestureRecognizer.new),
        },
        onMapCreated: (controller) {
          final pixelRatio = MediaQuery.of(context).devicePixelRatio;
          final padding = 12.34;

          controller.moveCamera(
            CameraUpdate.newBounds(
              bounds,
              focusRect: ScreenRect(
                topLeft: ScreenPoint(
                  x: padding * pixelRatio,
                  y: padding * pixelRatio,
                ),
                bottomRight: ScreenPoint(
                  x: (context.size!.width - padding) * pixelRatio,
                  y: (context.size!.height - padding) * pixelRatio,
                ),
              ),
            ),
          );
        },
        mapObjects: [],
        zoomGesturesEnabled: false,
        rotateGesturesEnabled: false,
        scrollGesturesEnabled: false,
        tiltGesturesEnabled: false,
      );
DCrow commented 5 months ago

Добрый день!

Это бага, падать приложение от такого не должно. В мастере исправил.