From ee2d7e0dc471372773b691a0364a3a0fa4879b22 Mon Sep 17 00:00:00 2001 From: Stephan Partzsch Date: Thu, 23 Oct 2025 02:06:50 +0200 Subject: [PATCH] Updates drawable size of metal view after it is attached to display hierarchy. (#3903) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- platform/ios/src/MLNMapView+Metal.mm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/platform/ios/src/MLNMapView+Metal.mm b/platform/ios/src/MLNMapView+Metal.mm index d17bd09be..67b4a4313 100644 --- a/platform/ios/src/MLNMapView+Metal.mm +++ b/platform/ios/src/MLNMapView+Metal.mm @@ -157,7 +157,7 @@ void MLNMapViewMetalImpl::createView() { } id device = (__bridge id)resource.getBackend().getDevice().get(); - const auto scaleFactor = MLNEffectiveScaleFactorForView(resource.mtlView); + const auto scaleFactor = MLNEffectiveScaleFactorForView(mapView); resource.mtlView = [[MTKView alloc] initWithFrame:mapView.bounds device:device]; resource.mtlView.delegate = resource.delegate; @@ -217,9 +217,15 @@ UIImage* MLNMapViewMetalImpl::snapshot() { void MLNMapViewMetalImpl::layoutChanged() { const auto scaleFactor = MLNEffectiveScaleFactorForView(mapView); - const auto screenSize = mapView.window.screen.nativeBounds.size; - size = { static_cast(screenSize.width * scaleFactor), - static_cast(screenSize.height * scaleFactor) }; + const auto screenSize = mapView.bounds.size; + + auto& resource = getResource(); + + resource.mtlView.contentScaleFactor = scaleFactor; + resource.mtlView.drawableSize = CGSizeMake(screenSize.width * scaleFactor, screenSize.height * scaleFactor); + + size = { static_cast(resource.mtlView.drawableSize.width), + static_cast(resource.mtlView.drawableSize.height) }; } MLNBackendResource* MLNMapViewMetalImpl::getObject() {