Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map Rendering Fails on Second Load with mappable_maps_mapkit_lite #1

Open
majdhorani opened this issue Sep 8, 2024 · 0 comments
Open

Comments

@majdhorani
Copy link

majdhorani commented Sep 8, 2024

When using mappable_maps_mapkit_lite (^4.7.2-beta4), the map loads correctly the first time, but on subsequent attempts, it fails to render and crash.

oM6y7k6L7FAs/uIsYvGc <warn>: Vendor: 4203
S3y7Y7dbKgkQPRRIjzXc <warn>: Physical device: Apple iOS simulator GPU (285344746)
IrTzXHdnT7EWDD3UYZHX <warn>: Depth image format: D32_SFLOAT
BDRmrnc094iACeACynsz <warn>: Integrated GPU detected
nVvh0L4tFDFvi/HGrXtA <warn>: Dynamic MSAA: not supported
6AgiLJwobi9TriCmAKIP <warn>: Supported multisampling: 1; 4;
HrD3OmSnKxutHOawpdQ5 <warn>: Ignore an attempt to render into the viewport with zero dimensions
XuJz7jcptbWLgyXNpfnb <error>: Config does not have information for layer map
XuJz7jcptbWLgyXNpfnb <error>: Config does not have information for layer vskl2
XuJz7jcptbWLgyXNpfnb <error>: Config does not have information for layer sat
fpz2c+NxDiNKIhJ8dBcC <error>: (VK_NOT_READY) Can't submit drawing commands

Code Sample:

late final AppLifecycleListener _lifecycleListener;
MapWindow? _mapWindow;
bool _isMapkitActive = false;
bool showMap = false;

@override
void initState() {
  super.initState();
  _startMapkit();

  _lifecycleListener = AppLifecycleListener(
    onResume: () async {
      _startMapkit();
      _setMapTheme();
    },
    onInactive: () {
      _stopMapkit();
    },
  );
}

@override
Widget build(BuildContext context) {
  if (MediaQuery.of(context).size.width == 0 ||
      MediaQuery.of(context).size.height == 0) {
    return const SizedBox.shrink();
  }

  return MappableMap(
    onMapCreated: _onMapCreated,
    platformViewType: PlatformViewType.Hybrid,
  );
}

@override
void dispose() {
  _stopMapkit();
  _lifecycleListener.dispose();
  widget.onMapDispose?.call();
  super.dispose();
}

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

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

void move({required double latitude, required double longitude, double zoom = 14}) {
  if (_mapWindow != null) {
    _mapWindow!.map.move(CameraPosition(
        Point(latitude: latitude, longitude: longitude),
        zoom: zoom,
        azimuth: 150.0,
        tilt: 30.0));
  }
}

void _onMapCreated(MapWindow window) {
  widget.onMapCreated(window);
  _mapWindow = window;
  move(latitude: 25.2048, longitude: 55.2708, zoom: 15);
  _setMapTheme();
}

void _setMapTheme() {
  _mapWindow?.map.nightModeEnabled =
      Theme.of(context).brightness == Brightness.dark;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant