Skip to content

[BUG][Web] Crash in Release mode with v0.25.0 (Uncaught Error / Minification issues) #708

@R-3MY

Description

@R-3MY

Platforms

web

Version of flutter maplibre_gl

0.25.0

Bug Description

Hi, I am encountering a critical issue with version 0.25.0 on Web. Everything works perfectly in Debug mode, but the app crashes in Release mode (flutter run -d chrome --release).

It seems related to minification or JS interop issues with the new version (Dart objects not being properly handled/converted for the JS side in release).

I can confirm the issue only appear in release version of 0.25.0 and is not present in 0.24.1 at all.

Logs from 0.24.1 :
GETTING LAYERS...
js_primitives.dart:28 LAYERS : [background, coastline, countries-fill, countries-boundary, geolines, geolines-label, countries-label, crimea-fill, BIiwKtKJWt_0, BIiwKtKJWt_1, MgZ2UT3c6x_0, hPVt9b0hzL_0, aa3uAygkb1_0, aa3uAygkb1_1]

Steps to Reproduce

Create a new flutter project and add maplibre_gl: ^0.25.0 dependency to pubspec
Don't forget to add required js & css maplibre urls in index.html head (follow package instructions)
Run in release : flutter run -d chrome --release

Expected Results

List of layerIds.

Actual Results

Error in console :
GETTING LAYERS...

core_patch.dart:293 Uncaught Error
    at VG.$1 (maplibre_web_gl_platform.dart:1372:40)
    at ab.cm (iterable.dart:442:29)
    at be.n (iterable.dart:371:5)
    at Object.A (core_patch.dart:377:5)
    at core_patch.dart:364:23
    at aaN.a (async_patch.dart:339:19)
    at aaN.$2 (async_patch.dart:365:23)
    at Object.D (async_patch.dart:265:3)
    at p1.kS (maplibre_web_gl_platform.dart:1372:5)
    at main.dart:38:37
apU	@	core_patch.dart:293
apV	@	errors.dart:120
$0	@	zone.dart:1512
ax4	@	schedule_microtask.dart:119
axf	@	schedule_microtask.dart:49
$1	@	async_patch.dart:55
childList		
$1	@	async_patch.dart:75
akB	@	async_patch.dart:33
qX	@	zone.dart:1623
S9	@	zone.dart:1869
ja	@	future_impl.dart:763
eY	@	future_impl.dart:359
(anonymous)	@	feedback.dart:101
(anonymous)	@	async_patch.dart:339
$2	@	async_patch.dart:365
D	@	async_patch.dart:265
Si	@	feedback.dart:92
KJ	@	ink_well.dart:1220
(anonymous)	@	js_helper.dart:2635
L_	@	recognizer.dart:345
dW	@	recognizer.dart:326
KM	@	tap.dart:758
DO	@	tap.dart:383
KH	@	tap.dart:314
iA	@	recognizer.dart:721
(anonymous)	@	js_helper.dart:2646
TZ	@	pointer_router.dart:97
$2	@	pointer_router.dart:142
a9	@	linked_hash_map.dart:193
Er	@	pointer_router.dart:140
Ml	@	pointer_router.dart:130
iB	@	binding.dart:528
a3F	@	binding.dart:498
Ft	@	binding.dart:473
zR	@	binding.dart:394
wY	@	binding.dart:341
Wu	@	binding.dart:308
(anonymous)	@	js_helper.dart:2646
jt	@	platform_dispatcher.dart:1553
a79	@	platform_dispatcher.dart:292
(anonymous)	@	js_helper.dart:2657
me	@	main.dart.js:25800
$1	@	pointer_binding.dart:1070
$1	@	pointer_binding.dart:953
$1	@	pointer_binding.dart:576
a8o	@	zone.dart:1849
v6	@	zone.dart:1848
$1	@	zone.dart:1804
aw4	@	js_allow_interop_patch.dart:363
(anonymous)	@	js_allow_interop_patch.dart:132

Code Sample

import 'package:flutter/material.dart';
import 'package:maplibre_gl/maplibre_gl.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: MapTestPage());
  }
}

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

  @override
  State<MapTestPage> createState() => _MapTestPageState();
}

class _MapTestPageState extends State<MapTestPage> {
  MapLibreMapController? mapController;
  bool isLoaded = false;

  void _onMapCreated(MapLibreMapController controller) {
    mapController = controller;
  }

  Future<void> _getLayerIds() async {
    if (mapController == null) {
      debugPrint("MAPCONTROLLER NULL");
      return;
    }
    debugPrint("GETTING LAYERS...");
    var layers = await mapController!.getLayerIds();
    debugPrint("LAYERS : $layers");
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Test MapLibre 0.25.0")),
      floatingActionButton: FloatingActionButton(
        onPressed: _getLayerIds,
        child: const Icon(Icons.print),
      ),
      body: MapLibreMap(
        styleString: "https://demotiles.maplibre.org/style.json",
        initialCameraPosition: const CameraPosition(
          target: LatLng(46.603354, 1.888334),
          zoom: 5,
        ),
        onMapCreated: _onMapCreated,
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnext versionThis feature will added in the next versionweb

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions