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

Proxy js-ref-15 has been invalidated. #7

Closed
nickfloros opened this issue Jun 11, 2013 · 5 comments
Closed

Proxy js-ref-15 has been invalidated. #7

nickfloros opened this issue Jun 11, 2013 · 5 comments

Comments

@nickfloros
Copy link

Hi

building an app where I need to get the LatLng of where the users clicks on the map. The app uses web_ui. When It come to implement the onClick.listen call back I get the following error
#0 Proxy._forward (package:js/js.dart:1043:22)
#1 Proxy.
#2 MouseEvent.latLng (package:google_maps/src/core/events/mouse_event.dart:23:43)
#3 addLatLng.addLatLng (http://127.0.0.1:3030/C:/Projects/dart/TestMap/web/testmap.dart:19:18)
#4 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:191:14)
#5 _DelayedData.perform (dart:async/stream_impl.dart:348:23)
#6 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:420:18)
#7 _PendingEvents.schedule. (dart:async/stream_impl.dart:391:17)
#8 _asyncRunCallback._asyncRunCallback (dart:async/event_loop.dart:9:15)
#9 Timer.Timer. (dart:async-patch/timer_patch.dart:9:15)
#10 _timerFactoryClosure.. (file:///E:/b/build/slave/dartium-win-full-trunk/build/src/dart/tools/dom/src/native_DOMImplementation.dart:177:13)

Exception: Proxy js-ref-15 has been invalidated.

Also here is a screen shot of what the debugger thinks of the callback event variable.

eclipse

To simplify the app I created the following and still get the same error

import 'dart:html';

import 'package:google_maps/google_maps.dart' as gMap;

void main() {

  final mapOptions = new gMap.MapOptions()
      ..zoom=14
      ..center=new gMap.LatLng(34,-89)
      ..mapTypeId = gMap.MapTypeId.ROADMAP;

  final map = new gMap.GMap(query('#map_canvas'),mapOptions);  

  map.onClick.listen(addLatLng);
}


void addLatLng(gMap.MouseEvent event) {
  print('${event.latLng.lat}');
}
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <title>TestMap</title>
    <link rel="stylesheet" href="testmap.css">
    <link href="https://www.google-developers.appspot.com/maps/documentation/javascript/examples/default.css" rel="stylesheet"/>
  </head>
  <body>
    <div id="map_canvas" style="height:400px"></div>    
    <div id="sample_container_id">
      <p id="sample_text_id"></p>
    </div>

    <script src="http://maps.google.com/maps/api/js?sensor=false&libraries=geometry"></script>
    <script type="application/dart" src="testmap.dart"></script>
    <script src="packages/browser/dart.js"></script>
  </body>
</html>

Dev environment is

  • Win7 64bit
  • Dart SDK & Editor 0.5.13_r23552
  • google_maps api version 1.1.11
  • js package is 0.0.22

Please note that exactly the same program works fine on MacOS but the Dart editor SDK version is r23200.

I also tried implementing a simple interface to google maps api using js interop and the data returned to the callback function look equally strange - I was expecting a nice simple JSON format ; anyway.

Any thoughts?

Thanks

@nickfloros
Copy link
Author

BTW I get the same error when I run dart-google-maps-master/example/08-libraries/geometry/geometry-encodings/map.html using latest SDK version ..

#0      Proxy._forward (package:js/js.dart:1043:22)
#1      Proxy.[] (package:js/js.dart:967:30)
#2      MouseEvent.latLng (package:google_maps/src/core/events/mouse_event.dart:23:43)
#3      addLatLng.addLatLng (http://127.0.0.1:3030/C:/Projects/dart/dart-google-maps-master/example/08-libraries/geometry/geometry-encodings/page.dart:39:15)
#4      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:191:14)
#5      _DelayedData.perform (dart:async/stream_impl.dart:348:23)
#6      _StreamImplEvents.handleNext (dart:async/stream_impl.dart:420:18)
#7      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:391:17)
#8      _asyncRunCallback._asyncRunCallback (dart:async/event_loop.dart:9:15)
#9      Timer.Timer.<anonymous closure> (dart:async-patch/timer_patch.dart:9:15)
#10     _timerFactoryClosure.<anonymous closure>.<anonymous closure> (file:///E:/b/build/slave/dartium-win-full-trunk/build/src/dart/tools/dom/src/native_DOMImplementation.dart:176:13)

Exception: Proxy js-ref-21 has been invalidated. 

Thanks

@a14n a14n closed this as completed in 4f7620e Jun 11, 2013
@a14n
Copy link
Owner

a14n commented Jun 11, 2013

Version 1.1.12 should fix your problem. Thanks !

@nickfloros
Copy link
Author

Thanks for fixing this.

One more question; actually two

I am using the map in a mobile app. So the map is instantiated within a WebComponent; which is created every time the user wants to view the map. The problem with this approach is that the map looses its state ; location user moved map too, zoom level etc. Is there any other way to solve this problem other than manually tracking state?

I am asking because in the GWT version of on the same app I kept a reference to the instantiated map object so did not have this problem. this would probably not work in Dart as web_ui appears to work differently to GWT when it comes to moving div in view.

2 : Also my initial implementation I had followed a post of yours in http://stackoverflow.com/questions/10152177/google-maps-and-dart

import 'dart:html';
import 'package:js/js.dart' as js;
import 'package:google_maps/google_maps.dart';

void main() {
  js.scoped((){
    final mapOptions = new MapOptions()
      ..zoom = 8
      ..center = new LatLng(-34.397, 150.644)
      ..mapTypeId = MapTypeId.ROADMAP
      ;
    final map = new GMap(query("#map_canvas"), mapOptions);
  });
}

Is this still the correct approach? I noticed in your examples that js.scoped in not used any more

Thanks for your help

@a14n
Copy link
Owner

a14n commented Jun 12, 2013

For your first issue, you can keep the GMap instance in a static variable (or map depending if you have several components instances).
For your second issue you can get rid of js.scoped. It's not needed anymore by js-interop.

@nickfloros
Copy link
Author

Hmm very interesting .. I opted to track map centre and zoom rather than keeping a static reference.

In order to get onCenterChanged.listen and onZoomChanged.listen to access data from the map object I had to use js.retain(map) . otherwise I get the following error (this is from one of your examples)

Exception: Proxy js-ref-11 has been invalidated.
#0      Proxy._forward (package:js/js.dart:1043:22)
#1      Proxy.noSuchMethod (package:js/js.dart:1033:20)
#2      GMap.zoom (package:google_maps/src/core/map/map.dart:98:34)
#3      main.<anonymous closure> (http://127.0.0.1:3030/Users/nick/dart/dart-google-maps-master/example/02-events/event-properties/page.dart:24:25)
#4      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:191:14)
#5      _BufferingStreamSubscription._add (dart:async/stream_impl.dart:141:16)
#6      _SyncStreamController._sendData (dart:async/stream_controller.dart:107:23)
#7      _StreamController.add (dart:async/stream_controller.dart:48:16)
#8      SubscribeStreamProvider.add.<anonymous closure> (package:google_maps/src/utils.dart:81:75)
#9      List.forEach (dart:core-patch/growable_array.dart:182:8)
#10     SubscribeStreamProvider.add (package:google_maps/src/utils.dart:81:44)
#11     GEvent.getStreamProviderFor.<anonymous closure>.<anonymous closure> (package:google_maps/src/core/events/events.dart:89:26)

So back to my map WebComponent I implement the removed() method to clean up. Within it if I call js.release(map) I get an error somewhere deep inside dart.js.

So I drop js.release and everything works ;

I find that strange and let's hope that I have no memory leaks.

Again thanks for your assistance.

Nick

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

2 participants