Skip to content

Crash on iOS Geometry.fromBoundingBox #20

@MrJohnDev

Description

@MrJohnDev

Вылетает если Geometry.fromBoundingBox вызывается в onMapCreated

Assertion failed: false at /usr/local/place/sandbox-data/build_cache/yb/build_root/qrvk/002fcc/maps/mobile/libs/mapkit/map/idl/impl/yandex/maps/mapkit/map/map_dart_binding.cpp:148. Stacktrace:
	yandex_flutter_mapkit_map_Map_cameraPositionForGeometry
Code Example
import 'package:flutter/material.dart';
import 'package:yandex_maps_mapkit_lite/init.dart';
import 'package:yandex_maps_mapkit_lite/mapkit.dart';
import 'package:yandex_maps_mapkit_lite/mapkit_factory.dart';
import 'package:yandex_maps_mapkit_lite/yandex_map.dart';

void main() {
  const yaMapKey = String.fromEnvironment('YA_MAP_KEY');
  initMapkit(apiKey: yaMapKey);
  runApp(const MapApp());
}

class MapApp extends StatelessWidget {
  const MapApp({super.key});

  @override
  Widget build(_) => const MaterialApp(home: MapBug());
}

class MapBug extends StatefulWidget {
  const MapBug({super.key});

  @override
  State<MapBug> createState() => _MapBugState();
}

class _MapBugState extends State<MapBug> {
  bool _isMapkitActive = false;
  late final AppLifecycleListener _lifecycleListener;

  @override
  void initState() {
    _startMapkit();
    _lifecycleListener = AppLifecycleListener(
      onResume: _startMapkit,
      onInactive: _stopMapkit,
    );
    super.initState();
  }

  void _startMapkit() {
    if (_isMapkitActive) return;
    _isMapkitActive = true;
    mapkit.onStart();
  }

  void _stopMapkit() {
    if (!_isMapkitActive) return;
    _isMapkitActive = false;
    mapkit.onStop();
  }

  @override
  void dispose() {
    _stopMapkit();
    _lifecycleListener.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: YandexMap(
        onMapCreated: (mapWindow) async {
          // Wait To Fix Crash On iOS
          // await Future.delayed(const Duration(seconds: 3));

          const boundingBox = BoundingBox(
            Point(latitude: 55.60, longitude: 37.54),
            Point(latitude: 55.92, longitude: 37.7),
          );

          const geometry = Geometry.fromBoundingBox(boundingBox); // Crash

          final camPos = mapWindow.map.cameraPositionForGeometry(geometry);

          mapWindow.map.move(camPos);
        },
      ),
    );
  }
}

yandex_maps_mapkit_lite: 4.16.0-beta
macOS 15.5 24F74 darwin-x64
Flutter: 3.32.2
Xcode 16.4 (16F6)
CocoaPods version 1.16.2

Tested On:
iOS Simulator - 18.5
iOS Device - 16.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions