Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Multiple Maps EXEC_BAD_ACCESS TransformState::getLatLng() #1103

Closed
jonathanduty opened this issue Mar 25, 2015 · 16 comments
Closed

Multiple Maps EXEC_BAD_ACCESS TransformState::getLatLng() #1103

jonathanduty opened this issue Mar 25, 2015 · 16 comments
Assignees
Labels
crash iOS Mapbox Maps SDK for iOS
Milestone

Comments

@jonathanduty
Copy link

setup:
I modified the left and right navbar buttons to either push a new MBXViewController or pop it using the UINavigationController. I wanted to test navigating from one map to another using push/pop UINavigation controller.

Steps:
Open app. Let first map fully load. Hit right bar button to navigate to new map. Hit left button to navigate back to first map. Touch the screen, you get a EXEC_BAD_ACCESS

Thread 1Queue : com.apple.main-thread (serial)
#0  0x0018efb2 in mbgl::TransformState::getLatLng() const at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/src/mbgl/map/transform_state.cpp:98
#1  0x0018f953 in mbgl::TransformState::latLngForPixel(mbgl::vec2<double>) const at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/src/mbgl/map/transform_state.cpp:205
#2  0x00379bc0 in mbgl::Map::latLngForPixel(mbgl::vec2<double>) const at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/include/mbgl/map/map.hpp:152
#3  0x00367971 in -[MGLMapView convertPoint:toCoordinateFromView:] at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/platform/ios/MGLMapView.mm:1154
#4  0x00365d4b in -[MGLMapView trackGestureEvent:forRecognizer:] at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/platform/ios/MGLMapView.mm:992
#5  0x0035f652 in -[MGLMapView handlePanGesture:] at /Users/jonathanduty/Development/mapbox/mapbox-gl-native/platform/ios/MGLMapView.mm:626
#6  0x01923287 in _UIGestureRecognizerSendActions ()
@incanus
Copy link
Contributor

incanus commented Mar 25, 2015

[MGLMapView trackGestureEvent:forRecognizer:]

@bleege want to investigate?

@incanus incanus added iOS Mapbox Maps SDK for iOS crash labels Mar 25, 2015
@bleege bleege self-assigned this Mar 25, 2015
@jonathanduty
Copy link
Author

At first glance following variables are declared in global scope in MGLMapView:

mbgl::Map *mbglMap = nullptr;
MBGLView *mbglView = nullptr;
mbgl::SQLiteCache *mbglFileCache = nullptr;
mbgl::DefaultFileSource *mbglFileSource = nullptr;

When the second MGLMapView is dealloced, they are set to null giving the first MGLMapView zombie pointers.

@bleege
Copy link
Contributor

bleege commented Mar 26, 2015

This may be related to #1109.

@friedbunny
Copy link
Contributor

Got this just now on the latest master, including the #1112 merge (552522e).

In [MGLMapView trackGestureEvent:forRecognizer:] at:

CGPoint ptInView = CGPointMake([recognizer locationInView:recognizer.view].x, [recognizer locationInView:recognizer.view].y);

bleege added a commit that referenced this issue Mar 26, 2015
@bleege
Copy link
Contributor

bleege commented Mar 26, 2015

@friedbunny good catch ^^. In the light of day that shouldn't be too surprising as it's doing math with UI objects. I'll move it outside the background thread.

bleege added a commit that referenced this issue Mar 26, 2015
@bleege bleege mentioned this issue Mar 26, 2015
@incanus
Copy link
Contributor

incanus commented Mar 26, 2015

@friedbunny @bleege The gesture tracking is unrelated to @jonathanduty's original report, which is about 2+ maps in an app and global variable naming collision. Gesture discussion over in #1116.

@incanus
Copy link
Contributor

incanus commented Mar 26, 2015

@jonathanduty Question here: is this two issues or one? i.e. having two maps in the same app, is the problem with view controllers related or another issue? If related to two maps, I think we can push this off of the b1 milestone, but if it's something else, we might want to address it sooner.

@jonathanduty
Copy link
Author

@incanus both of these are related to having 2 maps in the same app, however both do not need to be visible at the same time for either of these bugs to happen.

  1. One appears to be due to scope collision when a map is destroyed before the others. I think this is a bug with how the variables are defined in the mapview.
  2. the second occurs when you have multiple maps and try to scroll one of them. This appears to be an issue down the stack with how we are using sqlite.

@incanus incanus added this to the iOS Beta 1 milestone Apr 6, 2015
@picciano
Copy link

Any workarounds for this until it can be fixed? This one hurts after adding a second map to my app.
Thanks!

@mb12
Copy link

mb12 commented Apr 15, 2015

If you don't need to view two maps simultaneously, just change the style pointing to your new source/style. Basically never delete MGLMapView object and reuse it when switching UIViewControllers.

@picciano
Copy link

That did the trick. Thanks.

@crazyBoat
Copy link

Can someone explain me how to share the map between views? The map returns nil for me by singleton instance.

@incanus incanus self-assigned this Apr 29, 2015
@incanus
Copy link
Contributor

incanus commented Apr 29, 2015

To summarize the current status here:

  • Workaround of moving map view between view controllers works if you don't need simultaneous visibility (i.e. don't need parent/child view controllers both with map views). @crazyBoat query a VC's view property or otherwise expose the map view in its public API for another VC to use. Not sure what you mean by a singleton — there is none such for map views.
  • We still need to fix the root case of not moving a view but having two views potentially overlapping lifetimes. Looking at this now.

@incanus
Copy link
Contributor

incanus commented Apr 29, 2015

Simple use case showing problems with 2+ map views:

https://github.com/incanus/PushTest

ios simulator screen shot apr 29 2015 5 23 42 pm

@incanus
Copy link
Contributor

incanus commented Apr 29, 2015

Related: #1102

@incanus
Copy link
Contributor

incanus commented Apr 30, 2015

Above 858bb5d seems to solve this simply. Currently piggybacking a solution to #1102 on top of it now.

incanus added a commit that referenced this issue Apr 30, 2015
fixes #1103: allow multiple maps by not using global pointers
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crash iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

No branches or pull requests

7 participants