mapsplugin / cordova-plugin-googlemaps

Google Maps plugin for Cordova
Apache License 2.0
1.66k stars 913 forks source link

Update: sometime blank screen (iOS) #374

Closed amsdamsgram closed 9 years ago

amsdamsgram commented 9 years ago

Hey,

I have a menu on the map with buttons in it. All my click events on these buttons are not fired at all. The map seem to catch everything. I also tried with your small project in the documentation to put the Fullscreen button on the map and it's not working either. Do you have any idea how to fix this / how to do this?

Thanks!

wf9a5m75 commented 9 years ago

Could you tell me your html code?

And did you read this description? https://github.com/wf9a5m75/phonegap-googlemaps-plugin/wiki/Map#mapsetclickable

amsdamsgram commented 9 years ago

Thank you for your quick response.

The map.setClickable is not what I'm looking for because my menu is always there. It's always on the map. I'm trying to do the same thing you did with your searchBox here: https://github.com/wf9a5m75/phonegap-googlemaps-plugin/wiki/Map#put-html-elements-on-the-map

But the button is not clickable, I always zoom on the map when I try to click on the button.

wf9a5m75 commented 9 years ago

Turn on the debug option: map.setDebuggable( true )

And could you take a screen record, then share it? ( video recording, then upload youtube or something)

amsdamsgram commented 9 years ago

Hey, thank you for your help. It finally worked. I didn't realize HTML elements have to be in the map container to be able to catch events on them. Also, I have two other questions:

1- I'm using a CSS3 transition to move a HTML element on the map when it is clicked. It works at the first click but when I try to click again on it after the transition, it's not working. Is there any refresh I need to do to make it work? I tried the refreshLayout() but it's still not working. If you have any ideas.

2- 50% of the time, my app is just a blank screen. The first view of my app needs a map. So I was thinking maybe there was some loading time issue with other plugins or with something else before trying to load the plugin or use it? Do you know anything about something like this? I'm thinking about that because sometimes it works perfectly.

Thank you!

wf9a5m75 commented 9 years ago

Answer 1: I have no idea. map.refreshLayout() is not related with CSS3. And this plugin does not manage any CSS transition.

Answer 2: Is there any error message in Logcat or xcode?

amsdamsgram commented 9 years ago

Wow that was quick!

There is no error in Xcode and I tried to log something at the initialization of my app but nothing happened. But I feel like Xcode is not logging all the errors which makes it hard to debug. But for sure, something is going wrong 50% of the time...

wf9a5m75 commented 9 years ago

Do you wait the MAP_READY event properly?

var map = plugin.google.maps.Map.getMap(...);

// map.addMarker(...);   <-----Not good timing.

map.on(plugin.google.maps.event.MAP_READY, function() {

   map.addMarker(...);

});
amsdamsgram commented 9 years ago

I have tried that but I still have the blank screen. But something is happening before going into any code because I have put log everywhere and nothing is displayed. I also don't have the usual message "your application is using google maps plugin" or something like that. It's probably a log coming from you.

wf9a5m75 commented 9 years ago

Could you show me the screen capture?

hirbod commented 9 years ago

Please check my answer at #395. Maybe it will help you I had some similar problems in the start of my app-development but managed to fix them.

xuzongque commented 9 years ago

For no console output problem, did you installed cordova console plugin? By default it is not installed in cordova 3 or later: https://github.com/apache/cordova-plugin-console For javascript console.log to appear in xcode, you need this plugin, or you could inspect the console from Safari's Web Inspector.

wf9a5m75 commented 9 years ago

@iDams Any update for this?

amsdamsgram commented 9 years ago

Hey,

Sorry for the long time response. For the blank screen, it still happens sometimes but less than before. I don't know what changed. I am waiting for the map ready event before adding markers. I didn't before so maybe it was part of the problem. When the blank screen appears none of my console log appear at all, so it's not even going through the code. Could it be a loading issue with all the plugins I use? Here is a list of my plugin just in case:

com.googlemaps.ios 1.9.2 "Google Map iOS SDK for Cordova"
com.ionic.keyboard 1.0.4 "Keyboard"
com.ququplay.websocket.WebSocket 0.1.0 "WebSocket"
org.apache.cordova.camera 0.3.5 "Camera"
org.apache.cordova.console 0.2.13 "Console"
org.apache.cordova.device 0.3.0 "Device"
org.apache.cordova.dialogs 0.3.0 "Notification"
org.apache.cordova.file 1.3.3 "File"
org.apache.cordova.geolocation 0.3.12 "Geolocation"
org.apache.cordova.inappbrowser 0.6.0 "InAppBrowser"
org.apache.cordova.media-capture 0.3.6 "Capture"
org.apache.cordova.plugin.softkeyboard 1.0.3 "SoftKeyboard"
org.apache.cordova.statusbar 0.1.10 "StatusBar"
plugin.google.maps 1.2.4 "phonegap-googlemaps-plugin"
plugin.http.request 1.0.0 "phonegap-http-request"

Also, I am getting this Objective-C error but I'm having a hard time to debug it.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'

Any tips to debug Objective-C errors? I am pretty sure it's coming from the bounds or the marker because it happened either when the app starts or when I move the map but I can't find what happened.

wf9a5m75 commented 9 years ago

@iDams

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'

is important information. Please post the whole xcode log, and the screen capture of Xcode.

Also if you are available, please take the screen record of iOS Simulator.

(Quick time) Read record your screen http://support.apple.com/en-us/HT201066

or

iShowU http://www.shinywhitebox.com/

amsdamsgram commented 9 years ago

Here is a screenshot of xCode with the full log. It's probably due to the process of adding a marker because it either happens at the beginning when I load the map for the first time with markers or when I move the map and add new markers. And when I don't add markers, it's working fine. screen shot 2015-02-23 at 3 54 09 pm

I'm not allowed by my company to show you the application sorry... Why do you need a record of the simulator? I might be able to answer you.

wf9a5m75 commented 9 years ago

@iDams Thanks, but the screen shot of xcode is really unuseful. Please show me the log (copy & past here), otherwise I can not help you.

wf9a5m75 commented 9 years ago

And in order to confirm your JS steps, please add the below code in your platforms/ios/(your project)/Plugins/plugin.google.maps/GoogleMaps/GoogleMaps.m

Line 211 (if you use master) https://github.com/wf9a5m75/phonegap-googlemaps-plugin/blob/master/src/ios/GoogleMaps/GoogleMaps.m#L211

NSLog("classAndMethod = %@", classAndMethod);

This outputs how did you execute JS code (just only class and method names, that does not include any data)

wf9a5m75 commented 9 years ago

I saw your screenshot carefully, but I can not detect anything. NSInvalidArgumentException means you pass invalid data that I don't design for it (typically number format is mismatch, or you pass JSON object rather than number, something like that).

amsdamsgram commented 9 years ago

Hmm I use a lot of JSON actually... I'm going to add the NSLog and paste you the result.

wf9a5m75 commented 9 years ago

At least I need to know what the methods order log. Probably I don't need your JSON data at this moment.

wf9a5m75 commented 9 years ago

I agree some people don't(can't) want to publish their code. If your company allows to you share with me in closed, send me to my email: wf9a5m75@gmail.com. Or if you use private git, invite me. I'll keep your secret. (I'm not interested in your secret)

amsdamsgram commented 9 years ago

Here is the Xcode log with the NSLog, hope it helps.

2015-02-23 17:06:07.199 Zup[41152:5854149] DiskCookieStorage changing policy from 2 to 0, cookie file: file:///Users/phonegap/Library/Developer/CoreSimulator/Devices/4E090854-CCD7-4CD9-B94E-59DDD45422BD/data/Containers/Data/Application/C800A064-F35F-4D1C-A1C4-19C9C5C07B20/Library/Cookies/Cookies.binarycookies
2015-02-23 17:06:07.554 Zup[41152:5854149] Multi-tasking -> Device: YES, App: YES
2015-02-23 17:06:07.572 Zup[41152:5854149] Unlimited access to network resources
2015-02-23 17:06:07.590 Zup[41152:5854149] 

Started backup to iCloud! Please be careful.
Your application might rejected by Apple if you store too much data.
For more information please read "iOS Data Storage Guidelines"
You could find it at the following address https://developer.apple.com/icloud/documentation/data-storage/ .

2015-02-23 17:06:07.954 Zup[41152:5854149] [CDVTimer][keyboard] 0.056982ms
2015-02-23 17:06:08.002 Zup[41152:5854149] [CDVTimer][file] 47.964036ms
2015-02-23 17:06:08.393 Zup[41152:5854149] [CDVTimer][statusbar] 390.475035ms
2015-02-23 17:06:08.393 Zup[41152:5854149] [CDVTimer][TotalPluginStartup] 439.049006ms
2015-02-23 17:06:08.962 Zup[41152:5854149] Resetting plugins due to page load.
2015-02-23 17:06:09.631 Zup[41152:5854149] This app uses phonegap-googlemaps-plugin version 1.2.4
2015-02-23 17:06:09.650 Zup[41152:5854149] locationManager::didFailWithError (null)
2015-02-23 17:06:09.717 Zup[41152:5854149] locationManager::didFailWithError (null)
2015-02-23 17:06:10.784 Zup[41152:5854149] Finished load of: file:///Users/phonegap/Library/Developer/CoreSimulator/Devices/4E090854-CCD7-4CD9-B94E-59DDD45422BD/data/Containers/Bundle/Application/DADE78B6-D2E9-4B5E-B2B4-348FD868E662/Zup.app/www/index.html
2015-02-23 17:06:11.130 Zup[41152:5854362] classAndMethod =Map.setOptions
2015-02-23 17:06:11.130 Zup[41152:5854369] classAndMethod =Map.setCenter
2015-02-23 17:06:11.131 Zup[41152:5854318] classAndMethod =Map.setZoom
2015-02-23 17:06:11.131 Zup[41152:5854315] classAndMethod =Map.getVisibleRegion
2015-02-23 17:06:11.131 Zup[41152:5854317] classAndMethod =Map.getCameraPosition
2015-02-23 17:06:11.132 Zup[41152:5854366] classAndMethod =Marker.createMarker
2015-02-23 17:06:11.161 Zup[41152:5854366] classAndMethod =Marker.setIcon
2015-02-23 17:06:11.192 Zup[41152:5854149] Google Maps SDK for iOS version: 1.9.14591.0
2015-02-23 17:06:12.788 Zup[41152:5854366] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001091bef35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010c9dbbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x00000001091bee6d +[NSException raise:format:] + 205
    3   Foundation                          0x000000010c6801bf +[NSJSONSerialization JSONObjectWithData:options:error:] + 67
    4   Zup                                 0x00000001088e8b48 -[NSString(CDVJSONSerializing) JSONObject] + 120
    5   Zup                                 0x00000001088e5486 __39-[CDVCommandQueue enqueueCommandBatch:]_block_invoke + 54
    6   libdispatch.dylib                   0x000000010cd32ba6 _dispatch_call_block_and_release + 12
    7   libdispatch.dylib                   0x000000010cd507f4 _dispatch_client_callout + 8
    8   libdispatch.dylib                   0x000000010cd3b15d _dispatch_root_queue_drain + 1097
    9   libdispatch.dylib                   0x000000010cd3c612 _dispatch_worker_thread2 + 52
    10  libsystem_pthread.dylib             0x000000010d0e8ef8 _pthread_wqthread + 314
    11  libsystem_pthread.dylib             0x000000010d0ebfb9 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
wf9a5m75 commented 9 years ago

Ah, ok.

I guess you pass strings for marker.setIcon() instead of JSONObject, because I wrote wrong description.

The correct way to use marker.setIcon(), like this.

marker.setIcon({
    'url': 'www/images/icon-yellow.png'
});

This problem is fixed in the next version, but I haven't released it yet. (Because many issues are still registered in the issue list)

amsdamsgram commented 9 years ago

I already had this issue and fixed it. Now this the arguments I pass to setIcon: {"url":"www/img/mypos.png","size":{"width":12,"height":12}}

wf9a5m75 commented 9 years ago

Is your app fine everything?

amsdamsgram commented 9 years ago

What do you mean?

wf9a5m75 commented 9 years ago

Is this issue still occurred?

amsdamsgram commented 9 years ago

Yes. The setIcon was already good, I fixed it few weeks ago. So this is not the problem :/

wf9a5m75 commented 9 years ago

Ok, there is no more information in your log. Please find out which statement cause this error by yourself (except if you share your code with me).

wf9a5m75 commented 9 years ago

Tentatively, please insert many NSLog into setIcon_ in the Marker.m file, then show me the log.

-(void)setIcon_:(GMSMarker *)marker iconProperty:(NSDictionary *)iconProperty
                pluginResult:(CDVPluginResult *)pluginResult
                callbackId:(NSString*)callbackId {
  NSString *iconPath = nil;
  CGFloat width = 0;
  CGFloat height = 0;
  CGFloat anchorX = 0;
  CGFloat anchorY = 0;

  NSLog(@"-----> setIcon_ is started.");  

  // The `url` property
  iconPath = [iconProperty valueForKey:@"url"];
  NSLog(@"-----> iconPath = %@", iconPath);

  // The `size` property
  if ([iconProperty valueForKey:@"size"]) {
    NSDictionary *size = [iconProperty valueForKey:@"size"];
    width = [[size objectForKey:@"width"] floatValue];
    height = [[size objectForKey:@"height"] floatValue];
    NSLog(@"-----> width = %d, height = %d", width, height);
  }

  if (iconPath) {
    NSRange range = [iconPath rangeOfString:@"http"];
    if (range.location == NSNotFound) {
      Boolean isTextMode = true;

      UIImage *image;
      if ([iconPath rangeOfString:@"data:image/"].location != NSNotFound &&
          [iconPath rangeOfString:@";base64,"].location != NSNotFound) {

      NSLog(@"-----> Base64 icon");
        /**
         * Base64 icon
         */
        isTextMode = false;
        NSArray *tmp = [iconPath componentsSeparatedByString:@","];

        NSData *decodedData;
        if ([PluginUtil isIOS7_OR_OVER]) {
          decodedData = [[NSData alloc] initWithBase64EncodedString:tmp[1] options:0];
        } else {
          decodedData = [NSData dataFromBase64String:tmp[1]];
        }
        image = [[UIImage alloc] initWithData:decodedData];
        if (width && height) {
          image = [image resize:width height:height];
        }

        // The `anchor` property for the icon
        if ([iconProperty valueForKey:@"anchor"]) {
          NSArray *points = [iconProperty valueForKey:@"anchor"];
          anchorX = [[points objectAtIndex:0] floatValue] / image.size.width;
          anchorY = [[points objectAtIndex:1] floatValue] / image.size.height;
          marker.groundAnchor = CGPointMake(anchorX, anchorY);
        }

      } else {
      NSLog(@"-----> Load the icon from local path");

        /**
         * Load the icon from local path
         */
        image = [UIImage imageNamed:iconPath];

        if (width && height) {
          image = [image resize:width height:height];
        }
      }

      NSLog(@"-----> image is created.");
      marker.icon = image;
      // The `anchor` property for the icon
      if ([iconProperty valueForKey:@"anchor"]) {
        NSArray *points = [iconProperty valueForKey:@"anchor"];
        anchorX = [[points objectAtIndex:0] floatValue] / image.size.width;
        anchorY = [[points objectAtIndex:1] floatValue] / image.size.height;
        marker.groundAnchor = CGPointMake(anchorX, anchorY);
      }

      // The `infoWindowAnchor` property
      if ([iconProperty valueForKey:@"infoWindowAnchor"]) {
        NSArray *points = [iconProperty valueForKey:@"infoWindowAnchor"];
        anchorX = [[points objectAtIndex:0] floatValue] / image.size.width;
        anchorY = [[points objectAtIndex:1] floatValue] / image.size.height;
        marker.infoWindowAnchor = CGPointMake(anchorX, anchorY);
      }
      NSLog(@"-----> send plugin result.");
      [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
    } else {
      NSLog(@"-----> Load the icon from over the internet.");
      /***
       * Load the icon from over the internet
       */
      NSData *imgData = [self.iconCache objectForKey:iconPath];
      if (imgData != nil) {
      NSLog(@"-----> imgData != nil");
        UIImage* image = [UIImage imageWithData:imgData];
        if (width && height) {
          image = [image resize:width height:height];
        }
        marker.icon = image;
        [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
      } else {
        dispatch_queue_t gueue = dispatch_queue_create("GoogleMap_addMarker", NULL);
        dispatch_sync(gueue, ^{
          NSURL *url = [NSURL URLWithString:iconPath];
      NSLog(@"-----> url = %@", url);
          NSData *data = [NSData dataWithContentsOfURL:url options:NSDataReadingMapped error:nil];

      NSLog(@"-----> iconPath = %@", iconPath);
          [self.iconCache setObject:data forKey:iconPath];

          UIImage* image = [UIImage imageWithData:data];
          if (width && height) {
            image = [image resize:width height:height];
          }
      NSLog(@"-----> image is created");
          marker.icon = image;

          // The `anchor` property for the icon
          if ([iconProperty valueForKey:@"anchor"]) {
            NSArray *points = [iconProperty valueForKey:@"anchor"];
            CGFloat anchorX = [[points objectAtIndex:0] floatValue] / image.size.width;
            CGFloat anchorY = [[points objectAtIndex:1] floatValue] / image.size.height;
            marker.groundAnchor = CGPointMake(anchorX, anchorY);
          }

          // The `infoWindowAnchor` property
          if ([iconProperty valueForKey:@"infoWindowAnchor"]) {
            NSArray *points = [iconProperty valueForKey:@"infoWindowAnchor"];
            CGFloat anchorX = [[points objectAtIndex:0] floatValue] / image.size.width;
            CGFloat anchorY = [[points objectAtIndex:1] floatValue] / image.size.height;
            marker.infoWindowAnchor = CGPointMake(anchorX, anchorY);
          }

      NSLog(@"-----> send plugin result");
          [self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
        });
      }
    }
  }
}
amsdamsgram commented 9 years ago

Ok I'm going to try that. Thanks. Also, I have put a exception breakpoint and it gives me this. Apparently it's coming from the JSON. screen shot 2015-02-23 at 3 54 09 pm

amsdamsgram commented 9 years ago

So with your NSLog, I got this:

2015-02-23 18:51:31.594 Zup[54597:5915716] -----> setIcon_ is started. 2015-02-23 18:51:31.594 Zup[54597:5915716] -----> iconPath = www/img/mypos.png 2015-02-23 18:51:31.594 Zup[54597:5915716] -----> width = 4, height = 173770741 2015-02-23 18:51:31.594 Zup[54597:5915716] -----> Load the icon from local path 2015-02-23 18:51:31.667 Zup[54597:5915716] -----> image is created. 2015-02-23 18:51:31.667 Zup[54597:5915716] -----> send plugin result. 2015-02-23 18:51:31.691 Zup[54597:5915716] Google Maps SDK for iOS version: 1.9.14591.0 2015-02-23 18:51:32.144 Zup[54597:5915716] Finished load of: file:///Users/phonegap/Library/Developer/CoreSimulator/Devices/4E090854-CCD7-4CD9-B94E-59DDD45422BD/data/Containers/Bundle/Application/36DA813F-3B5D-4889-A8BA-5B4BE82D3D63/Zup.app/www/index.html

And then the error.

EDIT: The height is huge, this is weird because I send {"url":"www/img/mypos.png","size":{"width":12,"height":12}}

wf9a5m75 commented 9 years ago

Hmm, the height is really weird.

wf9a5m75 commented 9 years ago

The value should be 4 as the same as width.

wf9a5m75 commented 9 years ago

Could you show me the iconValue? Insert the below code, please.

NSLog(@"-----> setIcon_ is started.");  

NSLog(@"---iconProperty");
NSLog(@"%@", iconProperty);
amsdamsgram commented 9 years ago

2015-02-23 19:13:21.720 Zup[58052:5930202] -----> setIcon_ is started. 2015-02-23 19:13:21.720 Zup[58052:5930202] ---iconProperty 2015-02-23 19:13:21.733 Zup[58052:5930202] { size = { height = 12; width = 12; }; url = "www/img/mypos.png"; } 2015-02-23 19:13:21.733 Zup[58052:5930202] -----> iconPath = www/img/mypos.png 2015-02-23 19:13:21.734 Zup[58052:5930202] -----> width = 4, height = 51111925 2015-02-23 19:13:21.734 Zup[58052:5930202] -----> Load the icon from local path 2015-02-23 19:13:21.789 Zup[58052:5930202] -----> image is created. 2015-02-23 19:13:21.789 Zup[58052:5930202] -----> send plugin result.

wf9a5m75 commented 9 years ago

Ok, I think this issue is already fixed in the test branch. Please try the test branch.

$> cordova plugin rm plugin.google.maps
$> rm -rf platforms/ios/(your project)/Plugins/plugin.google.maps
$> cordova plugin add https://github.com/wf9a5m75/phonegap-googlemaps-plugin#test --variable API_KEY_FOR_ANDROID=... --variable API_KEY_FOR_IOS=...

If you don't want to use the test branch, replace the setIcon_ method with this code https://github.com/wf9a5m75/phonegap-googlemaps-plugin/blob/test/src/ios/GoogleMaps/Marker.m#L408-L606

amsdamsgram commented 9 years ago

I just tried your test branch and I still get the error unfortunately. And I don't think the huge height is the problem because here is what I have when it's working good:

2015-02-24 11:29:36.517 Zup[63172:5956347] -----> setIcon_ is started.
2015-02-24 11:29:36.518 Zup[63172:5956347] ---iconProperty
2015-02-24 11:29:36.518 Zup[63172:5956347] {
    size =     {
        height = 15;
        width = 15;
    };
    url = "www/img/marker_rtpush_2.png";
}
2015-02-24 11:29:36.518 Zup[63172:5956347] -----> iconPath = www/img/marker_rtpush_2.png
2015-02-24 11:29:36.518 Zup[63172:5956347] -----> width = 4, height = 185935861

But then when I move the map, the error appears at some point.

EDIT: You did fix something because I don't have the error when I first display the map at all. Also I notice that the error is only happening in a specific area of the map, but it's working fine everywhere else. Sorry, I was doing my tests always in the same area so I didn't notice it. So this means, the error is coming from a specific marker I try to add. There might one case you don't handle in the adding marker process. I'll try to find the specific marker.

wf9a5m75 commented 9 years ago

That is good news. Thanks for finding out. I'll wait for new updates from you.

amsdamsgram commented 9 years ago

Hey, so without doing anything except trying your test branch, I don't get the error anymore. There might have a cache somewhere and this is why I was still having the error at the beginning. Thank you.

Also now, I'm trying to debug the blank screen problem where I only see your log "This app uses phonegap-googlemaps-plugin version %@". And none of the logs in my application. I have put NSLog in all the pluginInitialize function in GoogleMaps.m file but when the blank screen appears, it still goes until the end of this function. So I have a question, which function is called after pluginInitialize? Because something happens between this function and the moment it goes to my application.

wf9a5m75 commented 9 years ago

@iDams In the test branch, I deprecated the marker image caching. The marker image caching helps to improve the loading speed for the same icon, however, most of people doesn't use the same icons. In the end, it causes out of memory error. There is some code in the test branch, but I will remove them before releasing the next version.


After pluginInitialize() function, you will get deviceready event in the JS side. Then you might call plugin.google.maps.Map.getMap() at the first time. In www/googlemaps-cdv-plugin.js file, find getMap() method. This method executes cordova.exec function.

cordova.exec(successCallback, errorCallback, PLUGIN_NAME, 'getMap', args);

https://github.com/wf9a5m75/phonegap-googlemaps-plugin/blob/test/www/googlemaps-cdv-plugin.js#L306-L311

cordova.exec() invites the native side. In Cordova iOS version, Cordova framework always execute exec method in GoogleMaps.m file. https://github.com/wf9a5m75/phonegap-googlemaps-plugin/blob/test/src/ios/GoogleMaps/GoogleMaps.m#L222

In this method, using refactoring technique, execute other methods. For example,

Finally, the getMap method is executed. https://github.com/wf9a5m75/phonegap-googlemaps-plugin/blob/test/src/ios/GoogleMaps/GoogleMaps.m#L140


code flow

(native) pluginInitialize() ->
   (js) deviceready ->
     (js) Map.getMap() -> 
       (js) cordova.exec() -> 
         (native) exec in the GoogleMaps.m ->
           (native) getMap() method ->
             (native) sendResult ->
               (js) successCallback or errorCallback
amsdamsgram commented 9 years ago

Thank you for all these information.

I might have find something but I'm not sure. I have noticed that when the blank screen appears, it doesn't go in my event listener of the deviceready event. But apparently, you are using this event too and it always goes into yours. So the event is being fired but I'm not catching it sometimes. Could you give some information about this code please?

document.addEventListener("deviceready", function() {
  document.removeEventListener("deviceready", arguments.callee);
  plugin.google.maps.Map.isAvailable();
});

I don't understand the removeListener part. It might be because of this that I can't catch it sometimes because of some loading/running time issue?

wf9a5m75 commented 9 years ago

The deviceready event is fired from the Cordova framework, not from this plugin.

All Cordova plugin have pluginInitialize method. The Cordova framework executes all the pluginInitialize methods, then fire the deviceready event. The deviceready event is fired only one time. So you can not catch it. (And you don't need that)

wf9a5m75 commented 9 years ago

And if you can not deviceready event when you get the black screen, you need to check the pluginInitialize methods of all plugins you uses.

success case

App start ->
   plugin1.pluginInitialize() -> ok -> 
      plugin2.pluginInitialize() -> ok ->
         googlemaps.pluginInitialize() -> ok ->
           deviceready

error case

App start ->
   plugin1.pluginInitialize() -> ok -> 
      plugin2.pluginInitialize() -> error -> no more.

At least until @iDams , I have never heard the black screen issue. So I wonder one of plugins you use causes this error.

amsdamsgram commented 9 years ago

I finally found what was causing the blank screen error. You were right, there was an error in another plugin I use (com.ionic.keyboard). Sometimes, cordova.plugins.Keyboard is not defined. This is weird. I commented it and now it works!

Last problem, the app crash when I test on a real device. I think it's the memory crash you were talking about in another comment. This is happening when I move on the map and load other markers. I tried with less markers and it works fine.

wf9a5m75 commented 9 years ago

Good job, @iDams

The last problem is probably already fixed, because you use the test branch. The test branch does not cache marker images anymore.

So do you still happen, or no more (I hope)

amsdamsgram commented 9 years ago

I'm not using the test branch, I just replaced the _setIcon method with the code you gave me. Is there anything else on the test branch? Because my app crash with the new _setIcon method :/

wf9a5m75 commented 9 years ago

Many issues are fixed in the test branch.

On Fri, Feb 27, 2015, 12:04 PM iDams notifications@github.com wrote:

I'm not using the test branch, I just replaced the _setIcon method with the code you gave me. Is there anything else on the test branch? Because my app crash with the new _setIcon method :/

— Reply to this email directly or view it on GitHub https://github.com/wf9a5m75/phonegap-googlemaps-plugin/issues/374#issuecomment-76462239 .

amsdamsgram commented 9 years ago

Oh I'm going to test this branch then and I'll let you know

amsdamsgram commented 9 years ago

So it's working better on the test branch but my app still crash when I unzoom and get more markers... :/