Reproduction for flutter/flutter#192467.
The app rasterises one vector map scene (Natural Earth coastlines, borders,
rivers and city dots; ~83,000 points in 76 draw calls) offscreen with
Picture.toImage(3840, 2160) followed by Image.toByteData(rawRgba), three
times, then once at 7680x4320, and prints the timings. Nothing has to be
tapped.
flutter build apk --debug
adb install -r build/app/outputs/flutter-apk/app-debug.apk
adb logcat -c
adb shell am start -n dev.midorinokaze.impeller_mali_readback_repro/.MainActivity
adb logcat -d -s flutter
Expected log (Galaxy A25 5G, Mali-G57 MC2, Impeller-Vulkan):
Using the Impeller rendering backend (Vulkan).
[repro] 3840x2160 run 1: toImage 37 ms, toByteData 6016 ms (33177600 bytes)
toImage + toByteData for one image, three runs at 3840x2160, then one at
7680x4320, then 3840x2160 again:
| Device | SoC / GPU / driver | Android | Vulkan | OpenGLES |
|---|---|---|---|---|
| Samsung SC-42A (Galaxy A21) | Exynos 7884B / Mali-G71 MP2 / r26p0 | 11 | 14.97 / 14.90 / 15.18 s; 7680x4320: ErrorDeviceLost, every later draw fails |
0.79 / 0.51 / 0.47 s; 7680x4320: 3.6 s; after: 0.55 s |
| Samsung SM-A253C (Galaxy A25 5G) | MediaTek MT6835 / Mali-G57 MC2 / r38p1 | 16 | 6.05 / 6.03 / 5.80 s; 7680x4320: 27.6 s; after: 5.88 s | 0.50 / 0.15 / 0.14 s; 7680x4320: 1.4 s; after: 0.15 s |
| Samsung SC-51D (Galaxy S23) | Qualcomm SM8550 (kalama) / Adreno 740 / [email protected] |
16 | 0.58 / 0.23 / 0.22 s; 7680x4320: 0.63 s; after: 0.18 s | 0.32 / 0.18 / 0.11 s; 7680x4320: 1.2 s; after: 0.20 s |
| SHARP SH-RM12 (AQUOS sense3) | Qualcomm sdm660 / Adreno 508 | 11 | (engine fails to initialise Vulkan and falls back to OpenGLES) | 0.33 / 0.31 / 0.25 s; 7680x4320: 6.1 s; after: 0.39 s |
On the two Mali devices the Vulkan cost sits in the first toByteData (the
picture is actually rasterised there) and is 25-65x the OpenGLES time on the
same device. On the Adreno 740 the two backends are within a factor of two of
each other.
Galaxy A21 log for the 7680x4320 case on Vulkan:
E flutter : [ERROR:flutter/impeller/renderer/backend/vulkan/fence_waiter_vk.cc(171)] Break on 'ImpellerValidationBreak' to inspect point of failure: Fence waiter encountered an unexpected error. Tearing down the waiter thread.
E flutter : [ERROR:flutter/impeller/renderer/backend/vulkan/command_queue_vk.cc(72)] Break on 'ImpellerValidationBreak' to inspect point of failure: Failed to submit command: ErrorDeviceLost
E flutter : [ERROR:flutter/lib/ui/painting/image_encoding_impeller.cc(225)] Failed to submit commands.
[repro] 7680x4320 run 1: FAILED: Exception:
[repro] 3840x2160 after 7680x4320: FAILED: Exception:
To compare with OpenGLES, uncomment the ImpellerBackend meta-data in
android/app/src/main/AndroidManifest.xml and rebuild (debug builds only;
the entry is ignored in release).
The already projected pixel coordinates and paint parameters of the map that
the original app draws: drawRect for the ocean, drawPath (even-odd fill
plus a round-join stroke) per land / lake polygon, drawPath (round cap and
join stroke) per river / border line, drawCircle per city. The geometry is
derived from Natural Earth (public
domain). The format is described in lib/main.dart.