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

MGLMapView fails to bind EAGLDrawable when initialised with CGRect with no width and height #1572

Closed
duemunk opened this issue May 16, 2015 · 11 comments
Labels
crash Google Maps parity For feature parity with the Google Maps SDK for Android or iOS iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS MapKit parity For feature parity with MapKit on iOS or macOS
Milestone

Comments

@duemunk
Copy link

duemunk commented May 16, 2015

Initialising a MGLMapView with CGRectZero:

let map = MGLMapView(frame: CGRectZero, accessToken: "_")

Crashes:

2015-05-16 16:56:35.782 SomeApp[35232:1946290] Failed to bind EAGLDrawable: <CAEAGLLayer: 0x17403a940> to GL_RENDERBUFFER 1
2015-05-16 16:56:35.783 SomeApp[35232:1946290] Failed to make complete framebuffer object 8cd6
2015-05-16 16:56:35.800 SomeApp[35232:1946361] [ERROR] {0}{Map}[Shader]: Program failed to validate: Validation Failed: Current draw framebuffer is invalid.

Current workaround

let map = MGLMapView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), accessToken: "_")
@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS crash labels May 16, 2015
@1ec5
Copy link
Contributor

1ec5 commented May 27, 2015

Via #1654, MGLMapView should also support CGRectNull.

@1ec5
Copy link
Contributor

1ec5 commented Jan 26, 2016

-[MGLMapView wakeGL:] should guard on CGRectIsEmpty(), and probably CGRectIsInfinite() while we’re at it. -setFrame: and -setBounds: should trigger this check and cause binding to occur if the frame changes from being empty (or infinite) to a reasonable value.

@1ec5
Copy link
Contributor

1ec5 commented Feb 22, 2016

Per #4065, initializing the map view with an empty frame no longer crashes. It looks like the validation step that was failing was removed in #2147.

@1ec5 1ec5 added bug and removed crash labels Feb 22, 2016
@1ec5 1ec5 changed the title MGLMapView crash error when initialised with CGRect with no width and height MGLMapView fails to bind EAGLDrawable when initialised with CGRect with no width and height Feb 22, 2016
@1ec5 1ec5 added this to the ios-v3.2.0 milestone Feb 25, 2016
@1ec5
Copy link
Contributor

1ec5 commented Jun 28, 2016

Per the comments in #5457, the crash has returned. However, I’m unable to reproduce it on either a simulator or a device.

@boundsj boundsj modified the milestones: ios-v3.4.0, ios-v3.3.0 Jun 29, 2016
@1ec5 1ec5 modified the milestones: ios-v3.4.0, ios-v3.3.0 Jul 1, 2016
@1ec5
Copy link
Contributor

1ec5 commented Jul 1, 2016

We’re still unable to reproduce the crash, yet we do get reports about it in the wild. The fix would likely involve changes to mbgl, which we aren’t willing to take this close to a release. Punting to 3.4.0.

@DsrMedia
Copy link

DsrMedia commented Jul 4, 2016

@1ec5 completely unrelated to MGLMapView itself: we have an SDK that inits a WKWebView with CGRectMake(0, 0, 0, 0) and also rarely crashes in the wild (crash reports of only two 6S Plus). We've also had this issue in the past, the workaround was to init the UIWebView we had with 1px height and width, however that workaround is not an option for us anymore with the WKWebView and other changes we've made to the SDK. Now this issue has popped back up on the 27th and 28th of June. We can artificially "reproduce" the crash by putting NAN in the CGRectMake somewhere, which will crash the app and print the following error:

CALayerInvalidGeometry', reason: 'CALayer bounds contains NaN:

However reproducing it artificially doesn't help as we have no clue why it is NAN in the first place when we literally use: CGRectMake(0, 0, 0, 0) (or CGRectZero) without any calculations.

Let me know if this helps you and if you find out anything

@boundsj boundsj modified the milestones: ios-v3.4.0, ios-future Jul 11, 2016
@incanus
Copy link
Contributor

incanus commented Nov 4, 2016

Lots of debugging background yesterday in #6883, which we've closed in favor of the core problem here.

@brunoabinader
Copy link
Member

As per #8562, using a zeroed CGRect will cause the core to throw a runtime exception.

@1ec5
Copy link
Contributor

1ec5 commented Apr 4, 2017

Reopening: it’s very common for a UIView or NSView to be initialized with zero size and given a size at some point before or after being added to the view hierarchy. This crash is a gotcha for many developers.

@1ec5 1ec5 reopened this Apr 4, 2017
@1ec5 1ec5 added crash Google Maps parity For feature parity with the Google Maps SDK for Android or iOS macOS Mapbox Maps SDK for macOS MapKit parity For feature parity with MapKit on iOS or macOS and removed bug labels Apr 4, 2017
@1ec5
Copy link
Contributor

1ec5 commented Apr 4, 2017

@brunoabinader proposes that MGLMapView always create mbgl::Map with a minimum size of 64×64 points, even if MGLMapView and EAGLView themselves are smaller than 64×64 points. This might work, although it might also throw off any calculations that are dependent on the screen location of the center coordinate at initialization.

@1ec5
Copy link
Contributor

1ec5 commented Apr 10, 2017

#8562 ended up implementing the 64x64-point workaround described above, which should address this crash and console spew.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crash Google Maps parity For feature parity with the Google Maps SDK for Android or iOS iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS MapKit parity For feature parity with MapKit on iOS or macOS
Projects
None yet
Development

No branches or pull requests

7 participants