Skip to content

negative span value results in crash #30

@aytunch

Description

@aytunch

Crash Report:
Inside "TSClusterMapView.m":

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    ....
    if (MKMapRectSizeIsGreaterThanOrEqual(zoomTo, self.visibleMapRect)) {
        zoomTo = MKMapRectInset(zoomTo, zoomTo.size.width/4, zoomTo.size.width/4);
        //At this point zoomTo.size.height becomes negative
    }
    MKCoordinateRegion region = MKCoordinateRegionForMapRect(zoomTo); 
    //and negative zoomTo results in negative(invalid) region.span.latitudeDelta
    ....
    [self setRegion:region animated:YES];  
    //Which results in a crash in this line with the invalid region being set
}

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid Region <center:+40.97086950, +29.03882550 span:-0.00556946, +0.01978016>' ***
img_4418

Scenario:
Q:What makes (MKMapRectSizeIsGreaterThanOrEqual(zoomTo, self.visibleMapRect)) equal to YES?
A:In my particular case for some clusters(not leafs), when I touch on them the map starts zooming towards the center of the clusterAnnotationView which is good and expected. But for some reason, animation stops early and does not split the cluster that is selected. When the setRegion animation stops, I touch on the same cluster again and MKMapRectSizeIsGreaterThanOrEqual returns yes and I get the crash.
img_4419

Conclusion:
I can fork the project and make sure the region values are valid before fed into setRegion:Animated: but this is not the real issue. I want to know why the cluster does not get broken when touched on it and stops early and how to avoid this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions