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

Infinite loop zooming in beyond z23 — -[MGLScaleBar labels] #9359

Closed

Description

@1ec5

Zooming in beyond z23 causes a hang in iOS SDK v3.6.0-rc.1 when the scale bar is visible. Steps to reproduce:

  1. In iosapp, increase MGLMapView.maximumZoomLevel to a value above 23, such as 25.5:
    diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m
    index d3927374a..cdf316621 100644
    --- a/platform/ios/app/MBXViewController.m
    +++ b/platform/ios/app/MBXViewController.m
    @@ -197,6 +197,8 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) {
             }
             [self presentViewController:alertController animated:YES completion:nil];
         }
    +    
    +    self.mapView.maximumZoomLevel = 30;
     }
     
     - (void)saveState:(__unused NSNotification *)notification
  2. Zoom in as far as you can.

As soon as you zoom in beyond z23, iosapp hangs with this stack:

#0	0x000000011401cc58 in _Block_object_dispose ()
#1	0x00007fff51d09800 in 0x7fff51d09800 ()
#2	0x0000000111cc1dfb in -[_UITintColorVisitor _visitView:] ()
#3	0x0000000111cc24ba in _UIViewVisitorEntertainVisitors ()
#4	0x0000000111cc1655 in _UIViewVisitorRecursivelyEntertainDescendingVisitors ()
#5	0x0000000111cc1706 in _UIViewVisitorRecursivelyEntertainDescendingVisitors ()
#6	0x0000000111cc0ff8 in _UIViewVisitorEntertainDescendingTrackingVisitors ()
#7	0x0000000111957c0a in __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke ()
#8	0x0000000111957a7d in -[UIView(Hierarchy) _postMovedFromSuperview:] ()
#9	0x0000000111967a0a in -[UIView(Internal) _addSubview:positioned:relativeTo:] ()
#10	0x0000000111955cf8 in -[UIView(Hierarchy) addSubview:] ()
#11	0x000000010e275a86 in ::-[MGLScaleBar labels]() at /Users/mxn/hub/mapbox-gl-native/platform/ios/src/MGLScaleBar.mm:295
#12	0x000000010e275cd5 in ::-[MGLScaleBar updateLabels]() at /Users/mxn/hub/mapbox-gl-native/platform/ios/src/MGLScaleBar.mm:318
#13	0x000000010e275c55 in ::-[MGLScaleBar layoutSubviews]() at /Users/mxn/hub/mapbox-gl-native/platform/ios/src/MGLScaleBar.mm:312
#14	0x000000011196b55b in -[UIView(CALayerDelegate) layoutSublayersOfLayer:] ()
#15	0x0000000113bef904 in -[CALayer layoutSublayers] ()

At this frame, i keeps incrementing and labels keeps getting longer until the device runs out of memory. This occurs because:

Printing description of self->_row:
(MGLRow) _row = (distance = 2.2441804252561335E-314, numberOfBars = 140660471574320)

I reproduced this with the system locale set to one that uses U.S. units. iosapp was running on an iPhone 7 simulator, both in landscape and in portrait orientation.

I could get the map to zoom in to z23–z23.90 in Seven Corners, Virginia, United States or Ho Chi Minh City, but only z20.98 in Svalbard.

/cc @frederoni

Activity

  1. added
    iOS
    on Jun 23, 2017
  2. 1ec5 commented on Jun 23, 2017

    @1ec5
    ContributorAuthor

    -[MGLScaleBar maximumWidth] is based on the map view’s width, so it’s quite possible for the crash to occur at lower zoom levels if the developer gives the map view a different aspect ratio.

  3. added this to the ios-v3.6.0 milestone on Jun 23, 2017
  4. 1ec5 commented on Jun 23, 2017

    @1ec5
    ContributorAuthor

    This issue would’ve been caught by the static analyzer:

    /path/to/mapbox-gl-native/platform/ios/src/MGLScaleBar.mm:221:10: Passed-by-value struct argument contains uninitialized data (e.g., field: 'distance')
    /path/to/mapbox-gl-native/platform/ios/src/MGLScaleBar.mm:221:10: Passed-by-value struct argument contains uninitialized data (e.g., field: 'distance')
    
  5. 1ec5 commented on Jun 24, 2017

    @1ec5
    ContributorAuthor

    Fixed in #9360 on the release-ios-v3.6.0-android-v5.1.0 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashiOS

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions