JaffaKetchup / flutter_map_tile_caching

Plugin for flutter_map providing advanced & performant caching and bulk downloading functionality, with many options for region shapes and extra tools
https://pub.dev/packages/flutter_map_tile_caching
GNU General Public License v3.0
117 stars 72 forks source link

[BUG] Error on initialise #158

Closed djaygier closed 3 months ago

djaygier commented 3 months ago

What is the bug?

When starting the app in release mode it gives error, when starting the app in normal debug mode it gives no error. After the error it doesnt go past it, stays white screen.

I/flutter (10302): type 'Null' is not a subtype of type 'List<dynamic>' in type cast I/flutter (10302): #0 BackgroundIsolateBinaryMessenger.ensureInitialized.<anonymous closure> (package:flutter/src/services/_background_isolate_binary_messenger_io.dart:51) I/flutter (10302): #7 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184) I/flutter (10302): (elided 6 frames from dart:async)

my main function

`void main() async { WidgetsFlutterBinding.ensureInitialized();

try { await FMTCObjectBoxBackend().initialise(); } catch (e) { log(e.toString()); }

try { await EasyLocalization.ensureInitialized(); } catch (e) { log(e.toString()); }

runApp( EasyLocalization( saveLocale: true, supportedLocales: const [ Locale("en", "US"), Locale("nl", "NL"), Locale("es", "ES"), Locale("hu", "HU"), Locale("it", "IT"), Locale("fr", "FR"), Locale("ru", "RU"), Locale("de", "DE"), Locale("pt", "PT"), ], path: "assets/translations", fallbackLocale: const Locale("en", "US"), child: const MyApp(), ), ); }`

Here are my pubs:

dependencies: page_transition: ^2.1.0 flutter_map: ^7.0.1 flutter_map_tile_caching: ^9.1.0 flutter: sdk: flutter flutter_feather_icons: ^2.0.0+1 google_fonts: ^6.2.1 intl: ^0.19.0 firebase_core: ^2.32.0 cloud_firestore: ^4.17.5 firebase_auth: ^4.20.0 geolocator: ^12.0.0 shared_preferences: ^2.2.3 geocoding: ^3.0.0 flutter_stripe: ^10.1.1 http: ^1.2.1 google_nav_bar: ^5.0.6 font_awesome_flutter: ^10.7.0 image_picker: ^1.1.2 firebase_storage: ^11.7.7 path_provider: ^2.1.3 uuid: ^4.4.0 camera: ^0.11.0+1 path: ^1.9.0 flutter_vector_icons: ^2.0.0 flutter_typeahead: ^5.2.0 cached_network_image: ^3.3.1 fast_cached_network_image: ^1.2.9 latlong2: ^0.9.1 email_validator: ^2.1.17 google_sign_in: ^6.2.1 photo_view: ^0.15.0 firebase_analytics: ^10.10.7 countup: ^0.1.4 animations: ^2.0.11 app_settings: ^5.1.1 username_generator: ^1.3.0 profanity_filter: ^2.0.0 image_cropper: ^7.0.4 in_app_review: ^2.0.9 url_launcher: ^6.3.0 blur: ^4.0.0 image: ^4.2.0 introduction_screen: ^3.1.14 image_gallery_saver: ^2.0.3 permission_handler: ^11.3.1 dio: ^5.4.3+1 sign_in_with_apple: ^6.1.0 syncfusion_flutter_core: ^25.2.7 firebase_messaging: ^14.9.4 numberpicker: ^2.1.2 upgrader: ^10.3.0 fluttertoast: ^8.2.6 lottie: ^3.1.2 device_info_plus: ^10.1.0 flutter_svg: ^2.0.10+1 easy_localization: ^3.0.7 flag: ^7.0.0 sliding_up_panel: ^2.0.0+1 syncfusion_flutter_maps: ^25.2.7 android_id: ^0.4.0 flutter_image_compress: ^2.3.0 fl_chart: ^0.68.0 http_parser: ^4.0.2 loading_animation_widget: ^1.2.1 csv: ^6.0.0 shimmer: ^3.0.0 confetti: ^0.7.0 flutter_animate: ^4.5.0 smooth_page_indicator: ^1.1.0 syncfusion_flutter_datepicker: ^25.2.7 weather_animation: ^1.0.1 package_info_plus: ^8.0.0 auto_size_text: ^3.0.0 ntp: ^2.0.0 pay: ^2.0.0 flutter_map_heatmap: ^0.0.7 version: ^3.0.2 firebase_cached_image: ^0.6.0 flutter_cache_manager: ^3.3.2 translator: ^1.0.0 flutter_native_splash: ^2.4.0

How can we reproduce it?

I don't really know why it happens.

Do you have a potential solution?

Find, understand and fix the error.

Platforms

Pixel 8 pro emulator API 34 Android 14 x86

Severity

Fatal: Causes the application to crash

JaffaKetchup commented 3 months ago

This looks potentially like a Flutter internal issue, as the issue is thrown here: https://github.com/flutter/flutter/blob/739e3bd0e8358d2bee3141e45ca4be6af91a36dd/packages/flutter/lib/src/services/_background_isolate_binary_messenger_io.dart#L51.

I can't reproduce this obviously, so I would be extremely greatful if you could try this code. Just comment out whatever is in your main.dart file currently, and paste this in, import libraries as necessary, then see what the result is. If it fails, then there's enough evidence here to file a good issue over on the Flutter repo.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  final rootIsolateToken = ServicesBinding.rootIsolateToken ??
      (throw StateError('Unable to retrieve token'));

  await Isolate.spawn(
    _worker,
    rootIsolateToken,
  );
}

void _worker(RootIsolateToken rootIsolateToken) {
  BackgroundIsolateBinaryMessenger.ensureInitialized(rootIsolateToken);
  print('Success');
}
JaffaKetchup commented 3 months ago

Without more information, this issue cannot be resolved. Please ping me if you can try the snippet above!