iOS: the map cannot be captured or read by flutter, because it is a platform view

Offen
#1,142 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

@Nixxx19 arbeitet bereits daran.

Seit 28.8.2026.

  • #1143 von @Nixxx19 — offen

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
25/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
dart, ios
Bereich
mobile, mobile-dev

Rechercherichtung

Beginne mit dem MapWidget-iOS-Platform-View-Pfad und reproduziere die im Issue beschriebene RepaintBoundary.toImage-Aufnahme. Prüfe den vorgeschlagenen Offscreen-Texture-Pfad aus dem Fork und kläre anschließend, ob er in ein separates Widget oder als Option von MapWidget gehört. Als abgeschlossen gilt die Arbeit, wenn die Kartenpixel in Aufnahmen erscheinen und die bestehende MapboxMap API, Interaktionen, das Logo und die Attribution weiterhin funktionieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

what happens

on ios the map is a UiKitView. uikit composites it, not flutter, so the map is not in flutter's scene. anything that needs to read the map back therefore reads nothing:

  • RepaintBoundary.toImage and toImageSync return a hole where the map is. screenshot a page with a map on it and you get everything except the map.
  • a custom ImageFilter.shader used as a backdrop samples an empty texture, so a shader driven surface over the map renders as whatever it does with no input. in our case that was solid black.
  • anything else that composites against what is beneath it has nothing beneath it.

plain BackdropFilter is fine, the engine special cases it, so this is not "you cannot blur the map". it is narrower and harder: you cannot get the map's pixels into flutter.

android does not have this problem. MapWidget there can render into a TextureView, which puts the map inside the flutter scene where everything can see it. there is no equivalent on ios.

why it is not just a flag we forgot to port

android's textureView switches the render surface inside a platform view that already composites in the flutter scene. on ios platform views are always uikit composited (flutter/flutter#43902), so the fix is not a flag, it is giving the map a real texture path.

how to reproduce
  1. put a MapWidget in a page
  2. wrap the page in a RepaintBoundary
  3. call toImage on it and draw the result

the map area comes back blank. everything drawn by flutter comes back fine.

the panel on the right is the capture. the map behind it is rendering perfectly, and the capture of it is white.

what we did about it

we have this working in a fork: the map is created without a platform view, hosted offscreen, and its frames are handed to FlutterTextureRegistry, so the widget tree gets a Texture and nothing else. annotations, the full MapboxMap api, pan, pinch, rotate, pitch, resize and the logo and attribution all work, and captures contain the map.

happy to open the pr. it is about 700 lines, three new files plus 20 lines touched in existing ones, and nothing changes for anyone using MapWidget.

before asking you to review that, two questions:

  1. is an ios texture path something you would take in principle, or is uikit composition a deliberate constraint?
  2. if you would take it, do you want it as a separate widget or as an option on MapWidget?
Vorherrschende Sprache
Dart
Sterne
382
Forks
205
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus mapbox/mapbox-maps-flutter

Alle Issues in mapbox/mapbox-maps-flutter

Ähnliche Issues

Weitere Issues zu Dart

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.