liodali / OSM-Routing-Client-Dart

flutter package for osrm client api and open source routing service
https://pub.dev/packages/routing_client_dart
MIT License
18 stars 12 forks source link

Illegal argument in isolate message #16

Closed smiesnyrobert closed 1 year ago

smiesnyrobert commented 1 year ago

Hi, can you please help me with this error?

Iam using this versions:

routing_client_dart: ^0.4.0 flutter_osm_plugin: ^0.53.3

i have this code:

void getRoute() {

    final manager = MyOSRMManager.custom(server: "myCustomServerUrl");

    List<LngLat> waypoints = [
      LngLat(
          lng: widget.userDetail.order!.waypointList[0].longitude,
          lat: widget.userDetail.order!.waypointList[0].latitude),
      LngLat(
          lng: widget.userDetail.order!.waypointList[1].longitude,
          lat: widget.userDetail.order!.waypointList[1].latitude),
    ];

    manager
        .getRoad(
          waypoints: waypoints,
          geometries: Geometries.polyline,
          steps: true,
        )
        .then((road) => {
              controller.drawRoadManually(
                  road.polyline!
                      .map((e) => GeoPoint(latitude: e.lat, longitude: e.lng))
                      .toList(),
                  RoadOption(
                    roadWidth: 10,
                    roadColor: Colors.blue,
                    zoomInto: true,
                  ))
            });
  }

and i get this error

E/flutter (25057): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Illegal argument in isolate message: (object extends NativeWrapper - Library:'dart:io' Class: _SecureFilterImpl@13069316)
E/flutter (25057): #0      Isolate._spawnFunction (dart:isolate-patch/isolate_patch.dart:399:25)
E/flutter (25057): #1      Isolate.spawn (dart:isolate-patch/isolate_patch.dart:379:7)
E/flutter (25057): #2      Isolate.run (dart:isolate:238:15)
E/flutter (25057): #3      compute (package:flutter/src/foundation/_isolates_io.dart:17:18)
E/flutter (25057): #4      OSRMManager.getRoad (package:routing_client_dart/src/osrm_manager.dart:71:21)
E/flutter (25057): <asynchronous suspension>

Can u please help? Thank you

liodali commented 1 year ago

are you calling getRoute in another isolate ?

smiesnyrobert commented 1 year ago

I have just normal button in widget and call it after button click

glonaldo70 commented 1 year ago

same problem

liodali commented 1 year ago

upgrade to new version for osrm dart client 0.4.2 contain some fixes

glonaldo70 commented 1 year ago

it what i'm using 0.4.2 . have i to add also flutter_osm_plugin in my dependencies?

liodali commented 1 year ago

if you're use another map no need for flutter osm plugin can provide me more code to understand more the issue

glonaldo70 commented 1 year ago

DetailSite( _selectedSite!, onSite: () async { Position mPosition = await _determinePosition(); print( " MY LOCATION IS: ${mPosition.longitude} + ${mPosition.latitude}"); List waypoints = [ LngLat( lng: mPosition.longitude, lat: mPosition.latitude), LngLat( lng: _selectedSite!.longitude!, lat: _selectedSite!.latitude!), ]; _road = await manager.getRoad( waypoints: waypoints, geometries: Geometries.polyline, steps: true, language: Languages.en, roadType: RoadType.car, overview: Overview.full); setState(() {}); }, )

liodali commented 1 year ago

this callback onSite is called inside isolate or just future ?

glonaldo70 commented 1 year ago

Just future void

smiesnyrobert commented 1 year ago

Ive created clean new project and here is the whole code. I get same error.

import 'package:flutter/material.dart';
import 'package:routing_client_dart/routing_client_dart.dart';
import 'package:testprojekt/MyOSRMManager.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(),
      floatingActionButton: FloatingActionButton(
        onPressed: getRoute,
        child: const Icon(Icons.add),
      ),
    );
  }

  void getRoute() {
    final manager = MyOSRMManager.custom(server: "xxxx");

    List<LngLat> waypoints = [
      LngLat(lng: 13.388860, lat: 52.517037),
      LngLat(lng: 13.397634, lat: 52.529407),
      LngLat(lng: 13.428555, lat: 52.523219),
    ];
    manager
        .getRoad(
          waypoints: waypoints,
          geometries: Geometries.polyline,
          steps: true,
        )
        .then((road) => {
              print("success"),
            });
  }
}

pubspec.yml

name: testprojekt
description: A new Flutter project.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.0.0+1

environment:
  sdk: '>=2.19.6 <3.0.0'

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  routing_client_dart: ^0.4.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0

flutter:
  uses-material-design: true
liodali commented 1 year ago

if you can that you intercept the response usinf dev tools and share it with me if it possible

smiesnyrobert commented 1 year ago

which response u mean? http response from server?

liodali commented 1 year ago

yeah

smiesnyrobert commented 1 year ago

{"code":"Ok","routes":[{"geometry":"mfp_I__vpAWBSBE?C?[BUBuALI@O@wAJK@UBMMC?AAKAe@FyBTC@E?IDIDA@M@]BUBSBA?E@E@A@IFWBG@C?WBm@FG@I@aBNG@i@FO@OBaBNG@M@mAFc@@}@Fu@DG?a@B[@qAF}@JA?[D_E`@SBO@ODA@UDA?ODE@GBC?uBNE?OAKCC_@AI]mCCUE[AK[iCUaBAMAMSsAE[k@sE_@_DAMACAKCQGi@AKQuACOKy@E_@G[Gc@]wBw@aFKw@y@mFCMAKIq@?KAQ?KIuDQmHEuB@U@U?OCq@?I?IASAg@ASMaF?OAi@?c@@c@Du@r@cH@U@I@G@I?G~@kJRyBf@uE@KFi@@KPuABMFc@D[@MT_C@QJ{@Ny@Ha@RiAfBuJF]DOh@yAHSf@aADIR_@JS@C@A@CJSWWEECEECOQe@a@CCUQaCkB{@y@GESO?_@?C?C?WIoCGqCAK?[MaEASMgDAi@AQ@YBKf@_ENg@D]T{ABIHm@FY@GBUJk@@IHcA?c@?QAQG]JKDC@ADCHOL]FOFUT{@BKTu@La@\\gANg@L_@DOJ[~@kBP[JSXg@^q@R]Ta@HQR]b@y@^s@Xg@JQHQP_@HQLMLKRIFAL?J@HBFBr@XNH^NHDTJNFTRRJd@LXFB@B?VB@V?N?F@jA@dB","legs":[{"steps":[{"geometry":"mfp_I__vpAWBSBE?C?[BUBuALI@O@wAJK@UBMMC?AAKAe@FyBTC@E?IDIDA@M@]BUBSBA?E@E@A@IFWBG@C?WBm@FG@I@aBNG@i@FO@OBaBNG@M@mAFc@@}@Fu@DG?a@B[@qAF}@JA?[D_E`@SBO@ODA@UDA?ODE@GBC?uBNE?OAKC","maneuver":{"bearing_after":355,"bearing_before":0,"location":[13.388798,52.517033],"type":"depart"},"mode":"driving","driving_side":"right","name":"Friedrichstraße","intersections":[{"out":0,"entry":[true],"bearings":[355],"location":[13.388798,52.517033]},{"out":0,"in":2,"entry":[true,false,false,true],"bearings":[0,90,180,270],"location":[13.38878,52.517149]},{"out":0,"in":2,"entry":[true,true,false,true],"bearings":[0,90,180,270],"location":[13.388643,52.518027]},{"out":0,"in":2,"entry":[true,true,false,true,false],"bearings":[30,90,180,270,315],"location":[13.388544,52.518716]},{"out":0,"in":1,"entry":[true,false,true,false],"bearings":[0,165,180,285],"location":[13.388255,52.520395]},{"out":0,"in":2,"entry":[true,true,false,true],"bearings":[0,45,180,225],"location":[13.388022,52.521758]},{"out":0,"in":1,"entry":[true,false,true],"bearings":[0,180,255],"location":[13.387898,52.52245]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[0,90,180],"location":[13.387799,52.523401]},{"lanes":[{"valid":false,"indications":["none"]},{"valid":false,"indications":["left"]},{"valid":true,"indications":["straight"]}],"out":0,"in":1,"entry":[true,false,true],"bearings":[0,180,270],"location":[13.387748,52.523877]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[0,90,180],"location":[13.3877,52.524433]},{"out":3,"in":1,"entry":[true,false,false,true],"bearings":[105,165,300,345],"location":[13.387337,52.526239]},{"out":0,"in":2,"entry":[true,false,false,false],"bearings":[0,105,165,255],"location":[13.387283,52.526386]}],"weight":138.3,"duration":135.5,"distance":1136.9},{"geometry":"yer_IeuupAC_@AI]mCCUE[AK[iCUaBAMAMSsAE[k@sE_@_DAMACAKCQGi@AKQuACOKy@E_@G[Gc@]wBw@aFKw@y@mFCMAKIq@?K","maneuver":{"bearing_after":71,"bearing_before":8,"location":[13.387228,52.527168],"modifier":"right","type":"turn"},"mode":"driving","driving_side":"right","name":"Torstraße","intersections":[{"out":0,"in":1,"entry":[true,false,true,true],"bearings":[75,195,255,330],"location":[13.387228,52.527168]},{"out":0,"in":1,"entry":[true,false,true],"bearings":[75,255,345],"location":[13.389147,52.527549]},{"out":0,"in":1,"entry":[true,false,true],"bearings":[75,255,330],"location":[13.391396,52.528032]},{"out":0,"in":2,"entry":[true,true,false,true],"bearings":[75,165,255,345],"location":[13.392444,52.528237]},{"out":0,"in":2,"entry":[true,true,false,true],"bearings":[75,120,255,330],"location":[13.393814,52.528526]},{"out":0,"in":1,"entry":[true,false,true],"bearings":[75,255,345],"location":[13.395724,52.528996]},{"out":0,"in":2,"entry":[true,true,false,true],"bearings":[90,180,255,345],"location":[13.397565,52.529429]}],"weight":124.899999999,"duration":124.899999999,"distance":750.1},{"geometry":"}sr_IevwpA","maneuver":{"bearing_after":0,"bearing_before":86,"location":[13.39763,52.529432],"type":"arrive"},"mode":"driving","driving_side":"right","name":"Torstraße","intersections":[{"in":0,"entry":[true],"bearings":[266],"location":[13.39763,52.529432]}],"weight":0,"duration":0,"distance":0}],"summary":"Friedrichstraße, Torstraße","weight":263.2,"duration":260.4,"distance":1887},{"steps":[{"geometry":"}sr_IevwpAAQ?KIuDQmHEuB@U@U?OCq@?I?IASAg@ASMaF?OAi@?c@@c@Du@r@cH@U@I@G@I?G~@kJRyBf@uE@KFi@@KPuABMFc@D[@MT_C@QJ{@Ny@Ha@RiAfBuJF]DOh@yAHSf@aADIR_@","maneuver":{"bearing_after":85,"bearing_before":0,"location":[13.39763,52.529432],"type":"depart"},"mode":"driving","driving_side":"right","name":"Torstraße","intersections":[{"out":0,"entry":[true],"bearings":[85],"location":[13.39763,52.529432]},{"lanes":[{"valid":true,"indications":["left"]},{"valid":true,"indications":["straight"]},{"valid":true,"indications":["straight","right"]}],"out":0,"in":2,"entry":[true,true,false,false],"bearings":[90,150,270,330],"location":[13.401337,52.529605]},{"out":0,"in":2,"entry":[true,false,true],"bearings":[90,165,285],"location":[13.401541,52.529618]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[105,195,285],"location":[13.405456,52.529405]},{"lanes":[{"valid":false,"indications":["left"]},{"valid":true,"indications":["straight"]},{"valid":true,"indications":["straight","right"]}],"out":1,"in":3,"entry":[true,true,true,false],"bearings":[30,105,210,285],"location":[13.409405,52.528711]},{"lanes":[{"valid":true,"indications":["straight"]},{"valid":true,"indications":["straight","right"]}],"out":0,"in":2,"entry":[true,true,false],"bearings":[105,165,285],"location":[13.409967,52.528591]},{"lanes":[{"valid":true,"indications":["straight"]},{"valid":true,"indications":["straight","right"]}],"out":0,"in":2,"entry":[true,false,false,false],"bearings":[105,165,285,330],"location":[13.410146,52.52855]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[120,210,285],"location":[13.411852,52.528201]}],"weight":203.400000000,"duration":203.400000000,"distance":1275.6},{"geometry":"gdr_Iie{pAJS@C@A@CJSWWEECEECOQ","maneuver":{"bearing_after":133,"bearing_before":133,"location":[13.415405,52.526922],"modifier":"left","type":"turn"},"mode":"driving","driving_side":"right","name":"","intersections":[{"lanes":[{"valid":false,"indications":["left"]},{"valid":false,"indications":["left"]},{"valid":false,"indications":["straight"]},{"valid":true,"indications":["straight"]},{"valid":true,"indications":["straight","right"]}],"out":1,"in":3,"entry":[false,true,true,false],"bearings":[30,135,210,315],"location":[13.415405,52.526922]},{"lanes":[{"valid":true,"indications":["left"]},{"valid":true,"indications":["left"]},{"valid":false,"indications":["straight"]},{"valid":false,"indications":["straight"]},{"valid":false,"indications":["straight"]}],"out":0,"in":3,"entry":[true,true,false,false],"bearings":[30,135,210,315],"location":[13.415657,52.52677]}],"weight":12,"duration":12,"distance":60.6},{"geometry":"aer_Iuh{pAe@a@CCUQaCkB{@y@GESO","maneuver":{"bearing_after":26,"bearing_before":32,"location":[13.415945,52.527047],"modifier":"straight","type":"new name"},"mode":"driving","driving_side":"right","name":"Prenzlauer Allee","intersections":[{"lanes":[{"valid":false,"indications":["left"]},{"valid":true,"indications":["straight"]},{"valid":true,"indications":["straight"]}],"out":0,"in":2,"entry":[true,false,false,true],"bearings":[30,120,210,315],"location":[13.415945,52.527047]}],"weight":18.2,"duration":18.2,"distance":177.6},{"geometry":"{mr_Iip{pA?_@?C?C?WIoCGqCAK?[MaEASMgDAi@AQ@YBKf@_ENg@D]T{ABIHm@FY@GBUJk@@IHcA?c@?QAQG]","maneuver":{"bearing_after":85,"bearing_before":28,"location":[13.417166,52.528458],"modifier":"right","type":"turn"},"mode":"driving","driving_side":"right","name":"Prenzlauer Berg","intersections":[{"out":1,"in":2,"entry":[true,true,false,false],"bearings":[30,90,210,315],"location":[13.417166,52.528458]},{"out":1,"in":3,"entry":[false,true,true,false],"bearings":[45,120,225,285],"location":[13.423592,52.528206]},{"out":1,"in":3,"entry":[true,true,false,false],"bearings":[45,105,210,300],"location":[13.423868,52.528136]}],"weight":57,"duration":57,"distance":548.7},{"geometry":"mkr_Iea}pAJKDC@ADCHOL]FOFUT{@BKTu@La@\\gANg@L_@DOJ[~@kBP[JSXg@^q@R]Ta@HQR]b@y@^s@Xg@JQHQP_@HQLMLKRI","maneuver":{"bearing_after":151,"bearing_before":67,"location":[13.424993,52.528068],"modifier":"right","type":"turn"},"mode":"driving","driving_side":"right","name":"Friedenstraße","intersections":[{"out":1,"in":2,"entry":[true,true,false,true],"bearings":[60,150,255,345],"location":[13.424993,52.528068]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[120,225,300],"location":[13.425818,52.52763]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[135,225,315],"location":[13.428041,52.526565]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[135,225,315],"location":[13.429337,52.525737]}],"weight":52.400000000,"duration":52.400000000,"distance":510.1},{"geometry":"_xq_Iac~pAFAL?J@HBFBr@XNH^NHDTJNFTRRJd@LXFB@B?VB","maneuver":{"bearing_after":174,"bearing_before":163,"location":[13.430405,52.524964],"modifier":"straight","type":"new name"},"mode":"driving","driving_side":"right","name":"Platz der Vereinten Nationen","intersections":[{"out":1,"in":2,"entry":[true,true,false],"bearings":[135,180,345],"location":[13.430405,52.524964]}],"weight":20.6,"duration":20.6,"distance":196.6},{"geometry":"mmq_Io~}pA@V?N?F@jA@dB","maneuver":{"bearing_after":267,"bearing_before":189,"location":[13.429678,52.523269],"modifier":"right","type":"continue"},"mode":"driving","driving_side":"right","name":"Platz der Vereinten Nationen","intersections":[{"lanes":[{"valid":false,"indications":["left"]},{"valid":false,"indications":["straight","left"]},{"valid":false,"indications":["straight"]},{"valid":true,"indications":["straight","right"]}],"out":3,"in":0,"entry":[false,false,true,true],"bearings":[15,90,180,270],"location":[13.429678,52.523269]}],"weight":6.9,"duration":6.9,"distance":76.4},{"geometry":"gmq_Imw}pA","maneuver":{"bearing_after":0,"bearing_before":268,"location":[13.428554,52.523239],"type":"arrive"},"mode":"driving","driving_side":"right","name":"Platz der Vereinten Nationen","intersections":[{"in":0,"entry":[true],"bearings":[88],"location":[13.428554,52.523239]}],"weight":0,"duration":0,"distance":0}],"summary":"Torstraße, Friedenstraße","weight":370.5,"duration":370.5,"distance":2845.5}],"weight_name":"routability","weight":633.7,"duration":630.9,"distance":4732.5}],"waypoints":[{"hint":"Uv8JgH9JmoUXAAAABQAAAAAAAAAgAAAAIXRPQYXNK0AAAAAAcPePQQsAAAADAAAAAAAAABAAAABi-gAA_kvMAKlYIQM8TMwArVghAwAA7wr2gjva","distance":4.231521214,"name":"Friedrichstraße","location":[13.388798,52.517033]},{"hint":"5D7dgak9iocGAAAACgAAAAAAAAB3AAAAppONQOodwkAAAAAA8TeEQgYAAAAKAAAAAAAAAHcAAABi-gAAfm7MABiJIQOCbswA_4ghAwAAXwX2gjva","distance":2.795148358,"name":"Torstraße","location":[13.39763,52.529432]},{"hint":"fSoYgP___38fAAAAUQAAACYAAAAeAAAAeosKQlNOX0Jq6iZCjsMGQh8AAABRAAAAJgAAAB4AAABi-gAASufMAOdwIQNL58wA03AhAwQAvxD2gjva","distance":2.226580806,"name":"Platz der Vereinten Nationen","location":[13.428554,52.523239]}]}

liodali commented 1 year ago

Oh sorry for that I found the issue ,it's my bad , I tried to improve current implementation and I forget that compute accept only top function and I moved parseRoad to mixin I will fix the issue and I will publish new version sorry again and thnx for your report just note I test in web and its working fine xD thats why I doubt at beginning

liodali commented 1 year ago

new version has being published 0.4.3

smiesnyrobert commented 1 year ago

thanks for fix, good job