tile loading improvement - fixes crashs when deallocating owning vc while tiles are loading #178

Merged
merged 1 commit into from Jun 25, 2012

Projects

None yet

4 participants

@danielgard

Fixed bug:
When scrolling the map fast and the map view is deallocated (e.g. UINavigationViewController pops the owner VC), still loading tiles forces a crash.

Technical bug description:
When dispatching from loading thread to main thread after image load, the dispatches are sued when main run loop is busy. While this time, the RMWebTileImage is deallocated... the call gets dispatched into a deallocated object.

How it is fixed:
It's fixed by changing the RMURLConnectionOperation from non-concurrent to concurrent behavior and schedule the NSURLConnection into MainRunloop instead of running a new thread.
The NSURLConnection delegate is now called on the main thread. Dispatch to main thread is no longer needed.
It still works asynchronously and perhaps a bit faster ;)

@danielgard danielgard tile loading improvement
fixed bug: when scrolling the map fast and dealloc the view while
scrolling, the still loading tiles forces a crash
7212043
@cyrilchandelier

Resolved my exc_bad_access on updateImageUsingImage:

@danielgard Hi Daniel, do you remember what was the purpose of this fix? I'm encountering a problem in which after using maps for quite a while, the tiles don't get downloaded. I've tracked the issue to these NSURLConnection not calling their delegates. I've reverted to the version previous to this fix and that does not happen, but I had to set the tile image layer's delegate to nil when being removed to avoid a crash. Is that the crash you were trying to avoid in the first time?

Btw, I've read this post https://groups.google.com/forum/#!topic/route-me-map/Bb8KP3gKZLI but I don't know the problem yet.

@frowing Hi! As far as i remember, this fix solved a problem with threading where some methods where called on the wrong queue. But i don't remember the details. We used the code with the fix in production for long time and didn't have any problems. Maybe the problem is related to newer iOS versions.
If you are new to route-me it's maybe a better idea to take a look at https://github.com/mapbox/mapbox-ios-sdk
It's the most advantaged and active fork of route-me. Also the tile loading works totally different/much more up-to-date there.

@tracyharton

So far this patch is working quite nicely.

@tracyharton tracyharton merged commit c556303 into route-me:master Jun 25, 2012
@jklimke jklimke pushed a commit to jklimke/mapbox-ios-sdk that referenced this pull request Feb 10, 2013
@incanus incanus fixes #178: fail map view init on invalid tile source 85d7f38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment