Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Crash: Simulator Crash (glDrawElements) on custom style when camera is moved #268

Closed
pappalar opened this issue Apr 1, 2022 · 31 comments
Labels
Apple Silicon bug Something isn't working iOS

Comments

@pappalar
Copy link

pappalar commented Apr 1, 2022

Hello.

I made a small demo app to verify the crash I have in my production app.
I tested this app with the default style and it works successfully.

We have a custom style which is way heavier than the default style, due the feature of the app.
As soon as we move the viewPort with something like:

mapView.setCenter(CLLocationCoordinate2D(latitude: 52.414812, longitude: 13.046378), zoomLevel: 16, animated: true)

MapLibre crashes (note it crashes even non-animated)

Thread 1: EXC_BAD_ACCESS (code=1, address=0x7faa2058fd90)

I would like to know if you could help us out.
We are not able to make the style simpler, but we would like to understand if there is something we can change to avoid the OpenGL Renderer to explode on camera movements.

Some Notes:

  • Manual user interactions (Pans, Zoom) are not crashing the map but are extremely laggy and slow
  • Programmatical changes are instantly crashing the renderer

Let me know if you want to have the Demo App (it's just a full screen map tbh)

StackTrace

Thread 1 Queue : com.apple.main-thread (serial)
#0	0x00007fff4020f189 in glvmRasterOpDepthStencilTest ()
#1	0x00007fff4025d195 in glvmInterpretFPTransformFour ()
#2	0x00007fff5bca3f8e in gldLLVMFPTransform ()
#3	0x00007fff5bcb80c4 in gldLLVMVecPolyRender ()
#4	0x00007fff5bca0540 in gldRenderFillPolygonPtr ()
#5	0x000000011d4d616e in 0x11d4d616e ()
#6	0x00007fff400fd6f7 in gleFlushAtomicFunc ()
#7	0x00007fff4014a10d in glDrawElements_IMM_ES2Exec ()
#8	0x0000000110f811fa in mbgl::gl::Context::draw(mbgl::gfx::DrawMode const&, unsigned long, unsigned long) ()
#9	0x0000000110fe4c54 in mbgl::gl::Program<mbgl::SymbolSDFTextProgram>::draw(mbgl::gfx::Context&, mbgl::gfx::RenderPass&, mbgl::gfx::DrawMode const&, mbgl::gfx::DepthMode const&, mbgl::gfx::StencilMode const&, mbgl::gfx::ColorMode const&, mbgl::gfx::CullFaceMode const&, mbgl::gfx::UniformValues<mbgl::TypeList<mbgl::uniforms::matrix, mbgl::uniforms::label_plane_matrix, mbgl::uniforms::coord_matrix, mbgl::uniforms::extrude_scale, mbgl::uniforms::texsize, mbgl::uniforms::fade_change, mbgl::uniforms::is_text, mbgl::uniforms::camera_to_center_distance, mbgl::uniforms::pitch, mbgl::uniforms::pitch_with_map, mbgl::uniforms::rotate_symbol, mbgl::uniforms::aspect_ratio, mbgl::uniforms::gamma_scale, mbgl::uniforms::device_pixel_ratio, mbgl::uniforms::is_halo, mbgl::uniforms::is_size_zoom_constant, mbgl::uniforms::is_size_feature_constant, mbgl::uniforms::size_t, mbgl::uniforms::size, mbgl::InterpolationUniform<mbgl::attributes::opacity>, mbgl::InterpolationUniform<mbgl::attributes::fill_color>, mbgl::InterpolationUniform<mbgl::attributes::halo_color>, mbgl::InterpolationUniform<mbgl::attributes::halo_width>, mbgl::InterpolationUniform<mbgl::attributes::halo_blur>, mbgl::uniforms::opacity, mbgl::uniforms::fill_color, mbgl::uniforms::halo_color, mbgl::uniforms::halo_width, mbgl::uniforms::halo_blur> > const&, mbgl::gfx::DrawScope&, mbgl::gfx::AttributeBindings<mbgl::TypeList<mbgl::attributes::pos_offset, mbgl::attributes::data<unsigned short, 4ul>, mbgl::attributes::pixeloffset, mbgl::attributes::projected_pos, mbgl::attributes::fade_opacity, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::opacity>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::fill_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_width>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_blur> > > const&, mbgl::gfx::TextureBindings<mbgl::TypeList<mbgl::textures::texture> > const&, mbgl::gfx::IndexBuffer const&, unsigned long, unsigned long) ()
#10	0x0000000111059cf8 in void mbgl::SymbolProgram<mbgl::SymbolSDFTextProgram, (mbgl::gfx::PrimitiveType)2, mbgl::TypeList<mbgl::attributes::pos_offset, mbgl::attributes::data<unsigned short, 4ul>, mbgl::attributes::pixeloffset>, mbgl::TypeList<mbgl::uniforms::matrix, mbgl::uniforms::label_plane_matrix, mbgl::uniforms::coord_matrix, mbgl::uniforms::extrude_scale, mbgl::uniforms::texsize, mbgl::uniforms::fade_change, mbgl::uniforms::is_text, mbgl::uniforms::camera_to_center_distance, mbgl::uniforms::pitch, mbgl::uniforms::pitch_with_map, mbgl::uniforms::rotate_symbol, mbgl::uniforms::aspect_ratio, mbgl::uniforms::gamma_scale, mbgl::uniforms::device_pixel_ratio, mbgl::uniforms::is_halo>, mbgl::TypeList<mbgl::textures::texture>, mbgl::style::TextPaintProperties>::draw<mbgl::gfx::Triangles>(mbgl::gfx::Context&, mbgl::gfx::RenderPass&, mbgl::gfx::Triangles const&, mbgl::gfx::DepthMode const&, mbgl::gfx::StencilMode const&, mbgl::gfx::ColorMode const&, mbgl::gfx::CullFaceMode const&, mbgl::gfx::IndexBuffer const&, mbgl::Segment<mbgl::TypeList<mbgl::attributes::pos_offset, mbgl::attributes::data<unsigned short, 4ul>, mbgl::attributes::pixeloffset, mbgl::attributes::projected_pos, mbgl::attributes::fade_opacity, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::opacity>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::fill_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_width>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_blur> > > const&, mbgl::gfx::UniformValues<mbgl::TypeList<mbgl::uniforms::matrix, mbgl::uniforms::label_plane_matrix, mbgl::uniforms::coord_matrix, mbgl::uniforms::extrude_scale, mbgl::uniforms::texsize, mbgl::uniforms::fade_change, mbgl::uniforms::is_text, mbgl::uniforms::camera_to_center_distance, mbgl::uniforms::pitch, mbgl::uniforms::pitch_with_map, mbgl::uniforms::rotate_symbol, mbgl::uniforms::aspect_ratio, mbgl::uniforms::gamma_scale, mbgl::uniforms::device_pixel_ratio, mbgl::uniforms::is_halo, mbgl::uniforms::is_size_zoom_constant, mbgl::uniforms::is_size_feature_constant, mbgl::uniforms::size_t, mbgl::uniforms::size, mbgl::InterpolationUniform<mbgl::attributes::opacity>, mbgl::InterpolationUniform<mbgl::attributes::fill_color>, mbgl::InterpolationUniform<mbgl::attributes::halo_color>, mbgl::InterpolationUniform<mbgl::attributes::halo_width>, mbgl::InterpolationUniform<mbgl::attributes::halo_blur>, mbgl::uniforms::opacity, mbgl::uniforms::fill_color, mbgl::uniforms::halo_color, mbgl::uniforms::halo_width, mbgl::uniforms::halo_blur> > const&, mbgl::gfx::AttributeBindings<mbgl::TypeList<mbgl::attributes::pos_offset, mbgl::attributes::data<unsigned short, 4ul>, mbgl::attributes::pixeloffset, mbgl::attributes::projected_pos, mbgl::attributes::fade_opacity, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::opacity>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::fill_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_width>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_blur> > > const&, mbgl::gfx::TextureBindings<mbgl::TypeList<mbgl::textures::texture> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) ()
#11	0x0000000111058a9f in auto void mbgl::(anonymous namespace)::drawText<mbgl::RenderSymbolLayer::render(mbgl::PaintParameters&)::$_1>(mbgl::RenderSymbolLayer::render(mbgl::PaintParameters&)::$_1 const&, mbgl::RenderTile const&, mbgl::LayerRenderData const&, mapbox::util::variant<std::__1::reference_wrapper<mbgl::Segment<mbgl::TypeList<mbgl::attributes::pos_offset, mbgl::attributes::data<unsigned short, 4ul>, mbgl::attributes::pixeloffset, mbgl::attributes::projected_pos, mbgl::attributes::fade_opacity, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::opacity>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::fill_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_width>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_blur> > > >, std::__1::reference_wrapper<std::__1::vector<mbgl::Segment<mbgl::TypeList<mbgl::attributes::pos_offset, mbgl::attributes::data<unsigned short, 4ul>, mbgl::attributes::pixeloffset, mbgl::attributes::projected_pos, mbgl::attributes::fade_opacity, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::opacity>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::fill_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_width>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_blur> > >, std::__1::allocator<mbgl::Segment<mbgl::TypeList<mbgl::attributes::pos_offset, mbgl::attributes::data<unsigned short, 4ul>, mbgl::attributes::pixeloffset, mbgl::attributes::projected_pos, mbgl::attributes::fade_opacity, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::opacity>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::fill_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_width>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_blur> > > > > > >, mbgl::SymbolBucket::PaintProperties const&, mbgl::PaintParameters const&)::'lambda'(mbgl::RenderSymbolLayer::render(mbgl::PaintParameters&)::$_1&, auto const&, auto const&, mbgl::SymbolSDFPart)::operator()<mbgl::SymbolSDFTextProgram, mbgl::gfx::UniformValues<mbgl::TypeList<mbgl::uniforms::matrix, mbgl::uniforms::label_plane_matrix, mbgl::uniforms::coord_matrix, mbgl::uniforms::extrude_scale, mbgl::uniforms::texsize, mbgl::uniforms::fade_change, mbgl::uniforms::is_text, mbgl::uniforms::camera_to_center_distance, mbgl::uniforms::pitch, mbgl::uniforms::pitch_with_map, mbgl::uniforms::rotate_symbol, mbgl::uniforms::aspect_ratio, mbgl::uniforms::gamma_scale, mbgl::uniforms::device_pixel_ratio, mbgl::uniforms::is_halo> >, mbgl::gfx::TextureBindings<mbgl::TypeList<mbgl::textures::texture> > >(mbgl::RenderSymbolLayer::render(mbgl::PaintParameters&)::$_1&, auto const&, auto const&, mbgl::SymbolSDFPart) const ()
#12	0x0000000111050d46 in void mbgl::(anonymous namespace)::drawText<mbgl::RenderSymbolLayer::render(mbgl::PaintParameters&)::$_1>(mbgl::RenderSymbolLayer::render(mbgl::PaintParameters&)::$_1 const&, mbgl::RenderTile const&, mbgl::LayerRenderData const&, mapbox::util::variant<std::__1::reference_wrapper<mbgl::Segment<mbgl::TypeList<mbgl::attributes::pos_offset, mbgl::attributes::data<unsigned short, 4ul>, mbgl::attributes::pixeloffset, mbgl::attributes::projected_pos, mbgl::attributes::fade_opacity, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::opacity>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::fill_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_width>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_blur> > > >, std::__1::reference_wrapper<std::__1::vector<mbgl::Segment<mbgl::TypeList<mbgl::attributes::pos_offset, mbgl::attributes::data<unsigned short, 4ul>, mbgl::attributes::pixeloffset, mbgl::attributes::projected_pos, mbgl::attributes::fade_opacity, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::opacity>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::fill_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_width>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_blur> > >, std::__1::allocator<mbgl::Segment<mbgl::TypeList<mbgl::attributes::pos_offset, mbgl::attributes::data<unsigned short, 4ul>, mbgl::attributes::pixeloffset, mbgl::attributes::projected_pos, mbgl::attributes::fade_opacity, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::opacity>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::fill_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_width>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::halo_blur> > > > > > >, mbgl::SymbolBucket::PaintProperties const&, mbgl::PaintParameters const&) ()
#13	0x000000011104f6f7 in mbgl::RenderSymbolLayer::render(mbgl::PaintParameters&) ()
#14	0x000000011107593f in mbgl::Renderer::Impl::render(mbgl::RenderTree const&) ()
#15	0x0000000111073ef3 in mbgl::Renderer::render(std::__1::shared_ptr<mbgl::UpdateParameters> const&) ()
#16	0x0000000111308081 in MGLRenderFrontend::render() [inlined] at /Users/runner/work/maplibre-gl-native/maplibre-gl-native/platform/ios/platform/darwin/src/MGLRendererFrontend.h:57
#17	0x000000011130803d in -[MGLMapView renderSync] at /Users/runner/work/maplibre-gl-native/maplibre-gl-native/platform/ios/platform/ios/src/MGLMapView.mm:1024
#18	0x00000001112bf690 in MGLMapViewImpl::render() [inlined] at /Users/runner/work/maplibre-gl-native/maplibre-gl-native/platform/ios/platform/ios/src/MGLMapView+Impl.mm:14
#19	0x00000001112bf671 in -[MGLMapViewImplDelegate glkView:drawInRect:] at /Users/runner/work/maplibre-gl-native/maplibre-gl-native/platform/ios/platform/ios/src/MGLMapView+OpenGL.mm:26
#20	0x00007fff4ef6a3f4 in -[GLKView _display:] ()
#21	0x00007fff28a71721 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#22	0x00007fff289937c9 in CA::Context::commit_transaction(CA::Transaction*, double, double*) ()
#23	0x00007fff289cae86 in CA::Transaction::commit() ()
#24	0x00007fff289cc104 in CA::Transaction::flush_as_runloop_observer(bool) ()
#25	0x00007fff2037267d in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#26	0x00007fff2036ce41 in __CFRunLoopDoObservers ()
#27	0x00007fff2036d3d9 in __CFRunLoopRun ()
#28	0x00007fff2036ca90 in CFRunLoopRunSpecific ()
#29	0x00007fff2cb72c8e in GSEventRunModal ()
#30	0x00007fff2508e90e in -[UIApplication _run] ()
#31	0x00007fff25093569 in UIApplicationMain ()
#32	0x00007fff59ab0cc2 in UIApplicationMain(_:_:_:_:) ()
#33	0x000000010f3a19a8 in static UIApplicationDelegate.main() ()
#34	0x000000010f3a1937 in static AppDelegate.$main() at Demo/AppDelegate.swift:10
#35	0x000000010f3a1a28 in main ()
#36	0x000000010f61af21 in start_sim ()
#37	0x000000011cc0751e in start ()
@zoziapps
Copy link

zoziapps commented Apr 1, 2022

I have the same problem since today – My style worked before, now it crashes.
Not sure what changed… maybe an Xcode update?

@username0x0a
Copy link

Yep, caused by iOS 15.4 Simulator. Similar issue has been posted on React wrapper for Mapbox issue tracker. 15.2 is still okay, but some investigation might be needed for future's sake.

@atierian
Copy link
Contributor

Thanks for opening this issue @racer1988.
A couple of questions:

  • Are you running on Apple Silicon or Intel?
  • Are you experiencing this crash on device as well?

@pappalar
Copy link
Author

@atierian Sorry for missing those details:

  • Issue is simulator only. I suspect it's due to OpenGL rendering in Simulators
  • It's happening on both Intel and M1 Chips.
  • It is happening always on 15.4 simulators.
  • It's happening also with default MapLibre style.
  • It's happening way faster when using a heavier custom style

To our tests this is mostly due to 15.4 environment. I will report if I can see issues on other simulator versions

@pappalar
Copy link
Author

Note:

  • my QA reports that Simulator Environment was also crashing before 15.4.
  • This is visible with fast map movement (or non-animated) in UI Automation Tests with older versions.

I suppose the issue was already present with previous simulators versions.
however it was visible only on our style with a really large number of sources and layers.

now it became a problem also on the default

@username0x0a
Copy link

I'd really prefer this issue to be treated as critical 🤔 either to accelerate finding a fix or speeding up the Metal adoption.

@wipfli
Copy link
Contributor

wipfli commented May 28, 2022

Thanks for the feeback @username0x0a It would be great to have more hands working on this. Do you think you would have time to help out?

@username0x0a
Copy link

username0x0a commented Jun 7, 2022

I don't want to panic prematurely 😓, but with Xcode 14 & iOS 16 Simulator, I'm getting an instant crash on launch, probably referencing something not going well in OS-level frameworks related to GL support.

Running the framework works okay on a physical device (no red alert escalation needed), no matter when run on iOS 16 device from Xcode 13 or 14. But the Simulator issues & development will probably become more serious. 🔥

@wipfli I could help with what I'm capable of, yet I'm not really an OpenGL/Metal guy, so any ideas in these areas are a bit of a black magic unfortunately. I'll at least try to experiment with the MetalANGLE path at this moment. 🤞

Update

The Metal branch (at least a bit older checkout with some customisations for a project where I used Mapbox) works pretty fine in the iOS 15.5 & 16 Simulators (not even mentioning the HW acceleration, that's huuge); the crashes I experience with the regular framework do not appear there, so far so good. 👌 Seems like pushing forward the MetalANGLE branch could be a topic for this summer holiday. 👀

@wipfli
Copy link
Contributor

wipfli commented Jun 8, 2022

Thanks, @username0x0a

@roblabs
Copy link
Collaborator

roblabs commented Jun 17, 2022

I was able to replicate this using the test app Mapbox GL (scheme iosapp) from mapbox/mapbox-gl-native-ios & the MapLibre GL test app.

Simulator Test on x86_64 iOS 14.5 iOS 15.5
mapbox/mapbox-gl-native-ios 💥
maplibre/maplibre-gl-native 💥 (watch video for issue)
sw_vers
# ProductName: macOS
# ProductVersion: 12.4
# BuildVersion: 21F79

uname -a
# Darwin oldSanJuan.local 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:22 PDT 2022;
# root:xnu-8020.121.3~4/RELEASE_X86_64 x86_64

xcodebuild -version
# Xcode 13.4.1
# Build version 13F100

Video paused to show the drawing defect in MapLibre GL
image


Video to show the drawing defect in MapLibre GL

15.5-Simulator-480.mov

@username0x0a
Copy link

username0x0a commented Jul 9, 2022

There's a chance I've successfully rebased + updated the MetalANGLE-backed code on top of the current main; I'll just test some cases & publish it in some forked repository so that it can be further enhanced.

I expect iOS 16 to really be a breaker here (at least for the Simulator which still uses some shady rendering routines even if real devices work okay) so I hope it could be moved somewhere. 🙏

@wipfli
Copy link
Contributor

wipfli commented Jul 11, 2022

Thanks @username0x0a for the update. Feel free to also make a draft pull request to this repo with your changes...

@roblabs
Copy link
Collaborator

roblabs commented Jul 13, 2022

Related to #163

@atierian atierian removed their assignment Jul 13, 2022
@Fab1n
Copy link

Fab1n commented Jul 21, 2022

Is there any workaround?

@maxammann
Copy link
Collaborator

maxammann commented Sep 6, 2022

Getting also a BAD_ACCESS crash on my M1. Running XCode with Rosetta did not change anything.

Thread 1 Queue : com.apple.main-thread (serial)
#0	0x0000000154713756 in glvmRasterOpDepthStencilTest ()
#1	0x0000000154762195 in glvmInterpretFPTransformFour ()
#2	0x000000014abc8f8e in gldLLVMFPTransform ()
#3	0x000000014abdd0c4 in gldLLVMVecPolyRender ()
#4	0x000000014abc5540 in gldRenderFillPolygonPtr ()
#5	0x000000014c4cf166 in 0x14c4cf166 ()
#6	0x000000015331e6f7 in gleFlushAtomicFunc ()
#7	0x000000015336b10d in glDrawElements_IMM_ES2Exec ()
#8	0x000000010c2961fa in mbgl::gl::Context::draw(mbgl::gfx::DrawMode const&, unsigned long, unsigned long) ()
#9	0x000000010c2f1ab4 in mbgl::gl::Program<mbgl::LineSDFProgram>::draw(mbgl::gfx::Context&, mbgl::gfx::RenderPass&, mbgl::gfx::DrawMode const&, mbgl::gfx::DepthMode const&, mbgl::gfx::StencilMode const&, mbgl::gfx::ColorMode const&, mbgl::gfx::CullFaceMode const&, mbgl::gfx::UniformValues<mbgl::TypeList<mbgl::uniforms::matrix, mbgl::uniforms::ratio, mbgl::uniforms::units_to_pixels, mbgl::uniforms::device_pixel_ratio, mbgl::uniforms::patternscale_a, mbgl::uniforms::patternscale_b, mbgl::uniforms::tex_y_a, mbgl::uniforms::tex_y_b, mbgl::uniforms::mix, mbgl::uniforms::sdfgamma, mbgl::InterpolationUniform<mbgl::attributes::blur>, mbgl::InterpolationUniform<mbgl::attributes::color>, mbgl::InterpolationUniform<mbgl::attributes::floorwidth>, mbgl::InterpolationUniform<mbgl::attributes::gapwidth>, mbgl::InterpolationUniform<mbgl::attributes::offset>, mbgl::InterpolationUniform<mbgl::attributes::opacity>, mbgl::InterpolationUniform<mbgl::attributes::pattern_to>, mbgl::InterpolationUniform<mbgl::attributes::pattern_from>, mbgl::InterpolationUniform<mbgl::attributes::width>, mbgl::uniforms::blur, mbgl::uniforms::color, mbgl::uniforms::floorwidth, mbgl::uniforms::gapwidth, mbgl::uniforms::offset, mbgl::uniforms::opacity, mbgl::uniforms::pattern_to, mbgl::uniforms::pattern_from, mbgl::uniforms::width> > const&, mbgl::gfx::DrawScope&, mbgl::gfx::AttributeBindings<mbgl::TypeList<mbgl::attributes::pos_normal, mbgl::attributes::data<unsigned char, 4ul>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::blur>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::floorwidth>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::gapwidth>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::offset>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::opacity>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::pattern_to>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::pattern_from>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::width> > > const&, mbgl::gfx::TextureBindings<mbgl::TypeList<mbgl::textures::image> > const&, mbgl::gfx::IndexBuffer const&, unsigned long, unsigned long) ()
#10	0x000000010c355876 in void mbgl::Program<mbgl::LineSDFProgram, (mbgl::gfx::PrimitiveType)2, mbgl::TypeList<mbgl::attributes::pos_normal, mbgl::attributes::data<unsigned char, 4ul> >, mbgl::TypeList<mbgl::uniforms::matrix, mbgl::uniforms::ratio, mbgl::uniforms::units_to_pixels, mbgl::uniforms::device_pixel_ratio, mbgl::uniforms::patternscale_a, mbgl::uniforms::patternscale_b, mbgl::uniforms::tex_y_a, mbgl::uniforms::tex_y_b, mbgl::uniforms::mix, mbgl::uniforms::sdfgamma>, mbgl::TypeList<mbgl::textures::image>, mbgl::style::LinePaintProperties>::draw<mbgl::gfx::Triangles>(mbgl::gfx::Context&, mbgl::gfx::RenderPass&, mbgl::gfx::Triangles const&, mbgl::gfx::DepthMode const&, mbgl::gfx::StencilMode const&, mbgl::gfx::ColorMode const&, mbgl::gfx::CullFaceMode const&, mbgl::gfx::IndexBuffer const&, std::__1::vector<mbgl::Segment<mbgl::TypeList<mbgl::attributes::pos_normal, mbgl::attributes::data<unsigned char, 4ul>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::blur>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::floorwidth>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::gapwidth>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::offset>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::opacity>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::pattern_to>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::pattern_from>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::width> > >, std::__1::allocator<mbgl::Segment<mbgl::TypeList<mbgl::attributes::pos_normal, mbgl::attributes::data<unsigned char, 4ul>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::blur>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::floorwidth>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::gapwidth>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::offset>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::opacity>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::pattern_to>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::pattern_from>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::width> > > > > const&, mbgl::gfx::UniformValues<mbgl::TypeList<mbgl::uniforms::matrix, mbgl::uniforms::ratio, mbgl::uniforms::units_to_pixels, mbgl::uniforms::device_pixel_ratio, mbgl::uniforms::patternscale_a, mbgl::uniforms::patternscale_b, mbgl::uniforms::tex_y_a, mbgl::uniforms::tex_y_b, mbgl::uniforms::mix, mbgl::uniforms::sdfgamma, mbgl::InterpolationUniform<mbgl::attributes::blur>, mbgl::InterpolationUniform<mbgl::attributes::color>, mbgl::InterpolationUniform<mbgl::attributes::floorwidth>, mbgl::InterpolationUniform<mbgl::attributes::gapwidth>, mbgl::InterpolationUniform<mbgl::attributes::offset>, mbgl::InterpolationUniform<mbgl::attributes::opacity>, mbgl::InterpolationUniform<mbgl::attributes::pattern_to>, mbgl::InterpolationUniform<mbgl::attributes::pattern_from>, mbgl::InterpolationUniform<mbgl::attributes::width>, mbgl::uniforms::blur, mbgl::uniforms::color, mbgl::uniforms::floorwidth, mbgl::uniforms::gapwidth, mbgl::uniforms::offset, mbgl::uniforms::opacity, mbgl::uniforms::pattern_to, mbgl::uniforms::pattern_from, mbgl::uniforms::width> > const&, mbgl::gfx::AttributeBindings<mbgl::TypeList<mbgl::attributes::pos_normal, mbgl::attributes::data<unsigned char, 4ul>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::blur>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::color>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::floorwidth>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::gapwidth>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::offset>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::opacity>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::pattern_to>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::pattern_from>, mbgl::ZoomInterpolatedAttribute<mbgl::attributes::width> > > const&, mbgl::gfx::TextureBindings<mbgl::TypeList<mbgl::textures::image> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) ()
#11	0x000000010c352c1e in mbgl::RenderLineLayer::render(mbgl::PaintParameters&) ()
#12	0x000000010c38a93f in mbgl::Renderer::Impl::render(mbgl::RenderTree const&) ()
#13	0x000000010c388ef3 in mbgl::Renderer::render(std::__1::shared_ptr<mbgl::UpdateParameters> const&) ()
#14	0x000000010c61d081 in MGLRenderFrontend::render() [inlined] at /Users/runner/work/maplibre-gl-native/maplibre-gl-native/platform/ios/platform/darwin/src/MGLRendererFrontend.h:57
#15	0x000000010c61d03d in -[MGLMapView renderSync] at /Users/runner/work/maplibre-gl-native/maplibre-gl-native/platform/ios/platform/ios/src/MGLMapView.mm:1024
#16	0x000000010c5d4690 in MGLMapViewImpl::render() [inlined] at /Users/runner/work/maplibre-gl-native/maplibre-gl-native/platform/ios/platform/ios/src/MGLMapView+Impl.mm:14
#17	0x000000010c5d4671 in -[MGLMapViewImplDelegate glkView:drawInRect:] at /Users/runner/work/maplibre-gl-native/maplibre-gl-native/platform/ios/platform/ios/src/MGLMapView+OpenGL.mm:26
#18	0x0000000120a253f4 in -[GLKView _display:] ()
#19	0x000000010bbcb721 in CA::Layer::layout_and_display_if_needed(CA::Transaction*) ()
#20	0x000000010baed7c9 in CA::Context::commit_transaction(CA::Transaction*, double, double*) ()
#21	0x000000010bb24e86 in CA::Transaction::commit() ()
#22	0x000000010bb26104 in CA::Transaction::flush_as_runloop_observer(bool) ()
#23	0x000000010ca7a67d in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
#24	0x000000010ca74e41 in __CFRunLoopDoObservers ()
#25	0x000000010ca753d9 in __CFRunLoopRun ()
#26	0x000000010ca74a90 in CFRunLoopRunSpecific ()
#27	0x0000000116325c8e in GSEventRunModal ()
#28	0x00000001250fc90e in -[UIApplication _run] ()
#29	0x0000000125101569 in UIApplicationMain ()
#30	0x00000001028f9e6f in main at /Users/ehrenamtskarte/projects/ehrenamtskarte/frontend/ios/Runner/AppDelegate.swift:5
#31	0x000000010b051f21 in start_sim ()
#32	0x0000000202a4b52e in start ()

@roblabs
Copy link
Collaborator

roblabs commented Sep 6, 2022

@maxammann — See discussion at maplibre/maplibre-gl-native-distribution#7

I do not recommend configuring Rosetta for either Xcode nor the Simulator, but you may find helpful workaround at the link above.

@username0x0a
Copy link

I'll try to create a public binary Swift package to use in the meantime 👍 – I need to use some somehow-hotfixed version, too. 😄

@pappalar
Copy link
Author

pappalar commented Sep 7, 2022

As the reporter of the issue, I would like to ask what is the plan of the community for this topic.

These are the recollection of points from discussions in various thread and my assumptions:

  • App using MapLibre on Simulators are crashing on all iOS Versions and Xcode Version

  • x86 Architecture has a easier time since it "probably" supports easily OpenGL

  • Arm Architecture (M1 etc) crashes immediately (probably lacks some OpenGL support)

  • Rosetta seems to alleviate the issue, because it probably helps with OpenGL support on ARM.

  • Metal seems to solve this issue, as it replaces OpenGL.

My gut feeling tell me that in order for MapLibre to continue support emulators devices is to migrate the main branch to metal.

This is a open-source community project, but I would like to ask the main maintainers (eg: @wipfli @nvanfleet ) if there is any intention to pursue this in a structured way, or due to the difficulty of the Metal Native Port, is something that set on the side to find resources.

(I unfortunately don't have sufficient knowledge of Metal to help with the issue itself)

References:

@maxammann
Copy link
Collaborator

Lets discuss this next week in the technical steering meeting.

@wipfli
Copy link
Contributor

wipfli commented Sep 7, 2022

Thanks for the summary @racer1988. I think that MapLibre GL Native will see substantial changes in the near future. Tonight we have an Advisory Council meeting with our sponsors and I will publish some meeting notes tomorrow probably. One big discussion topic will be how to move forward with Native...

@pappalar
Copy link
Author

pappalar commented Sep 7, 2022

@wipfli Thank you for the info!
Looking forward to the Meeting Notes. Would you kindly also link them here tomorrow?
Thanks!

@roblabs
Copy link
Collaborator

roblabs commented Sep 7, 2022

@racer1988 — Thank you for the original issue report back in April 2022. Your issue & logs was helpful in running down this problem around Apple Silicon and the iOS 15 SDK.  

Please see the discussion and my observations on the pass/failure table at maplibre/maplibre-gl-native-distribution#7. In my opinion, there is no short term workaround that comes from the MapLibre source. Each app developer using Apple Silicon, whether building from source or consuming the binary from a Swift Package needs to make a change detailed at maplibre/maplibre-gl-native-distribution#7.

I've updated your points (in italics) with my observations & comments from that link.

@racer1988: As the reporter of the issue, I would like to ask what is the plan of the community for this topic.

These are the recollection of points from discussions in various thread and my assumptions:

  • App using MapLibre on Simulators are crashing on all iOS Versions and Xcode Version.

Simulators running iOS 14 & 16 do not have an exception. iOS 15 does.

  • x86 Architecture has a easier time since it "probably" supports easily OpenGL.

This is good observation and possibly true. Targeting x86_64 in your app regardless of using Apple Silicon or Intel Macs seems to be right workaround for MapLibre running Open GL. The MapLibre Swift Package provides both arm64 & x86_64 binaries, so it's up to the app developer using MapLibre to configure a proper workaround.

  • Arm Architecture (M1 etc) crashes immediately (probably lacks some OpenGL support).

Only on iOS Simulators targeting arm64 and iOS 15 SDK and Apple Silicon Mac.

  • Rosetta seems to alleviate the issue, because it probably helps with OpenGL support on ARM.

Rosetta is not a recommended workaround

@pappalar
Copy link
Author

pappalar commented Sep 7, 2022

@roblabs Thank you for the detailed explanation!

Unfortunately for our use case we are unable to disable arm64 architecture (we did in the past) due to side effects in other libraries.

From your analysis, iOS 16 Beta seems like a promising solution to avoid the exception (EXC_BAD_ACCESS) and work on simulators with all architecture (despite the warning).

I am looking forward to the Meeting Notes for the future of MapLibre.

@username0x0a
Copy link

Guys, at this point, if you want to experiment, you can try this bundle of binaries:

https://sygic-travel-dist.s3.amazonaws.com/ios/libs/Mapbox-5.9.0.zip

(which has some extras for our commercial project like support for @3x resources) or build your own ones for testing from my forked repository, metal-support-new branch.

I'll try to update the proposed Pull request here in Maplibre so that is more usable for possible integration. 👍

@wipfli
Copy link
Contributor

wipfli commented Sep 9, 2022

Advisory Council meeting notes are here: maplibre/maplibre#104

@maxammann
Copy link
Collaborator

In 3 days iOS 16 will be released: https://www.apple.com/ios/ios-16/

Probably that means a new XCode update. According to @roblabs it does not crash with iOS 16 Preview. So my hopes are high that crashes will go away on all simulator versions 🤞🏼

@maxammann
Copy link
Collaborator

It works nicely on the new XCode version. I can life with that now :)

@birkskyum
Copy link
Member

Is XCode 14 a solution for everyone here?

@maxammann
Copy link
Collaborator

Is XCode 14 a solution for everyone here?

I havent yet tested older simulator versions.

@chganesh
Copy link

#337 (comment)

Please help on this issue

@louwers
Copy link
Collaborator

louwers commented Sep 22, 2023

We are dropping OpenGL support on iOS in favor of Metal.

Please try out the new pre-release and create a new issue if you run into any problems.

@louwers louwers closed this as completed Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apple Silicon bug Something isn't working iOS
Projects
None yet
Development

No branches or pull requests