Skip to content

Apple's open-source XNU kernel on Android phones: its own loader and drivers, Metal on the Adreno. Runs from RAM; a reboot gives the phone back to Android.

C

The iPhone XR's screen by default, the wallpaper's picture kept: scroll 118, swipes 110-115, home 106

yehorkaa87bf4851bcc9
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6f7b8d8..eb2ceb0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,7 @@ changes to it; the scripts named fetch the release and put the changes on.
- windows: `tools/metal-run.sh` sets `wallpaper_freeze=1` and `metal_defer=1`; an argument in `MORE` takes the place of a default of the same name
- metal: 250 touch samples a second instead of 125 change nothing (100 to 102); `touch_poll_us` stays 4000 in `tools/metal-run.sh`
- springboard: the status bar's legibility gradient (compositing filter `darkenSourceOver`) came out solid white over the top eighth of the home screen, on both Metal paths; it is drawn without the filter now, the wallpaper reaches the top and the status bar reads; why that filter's shader gives white is not known
+- windows: `tools/metal-run.sh` renders at the iPhone XR's screen by default, 828x1792 stretched to the panel: Settings' scroll 118 frames a second, swipes 110 to 115, home button 106, 1% of frames over 16.7 ms; the wallpaper is the picture a boot at the iPhone X's screen kept
- display: `fb_beam=1`, the default: each thread's rows are written behind the panel's scan line (2433 lines, 8338 us), and to the eye the moving bands are gone; it costs no frames (Settings' scroll 91 against 89, home button 89 to 92 against 81, swipes 101 against 99)
- docs: a short README and a front page by what you came to do; `docs/reference/metal.md` and its measurements; every boot-argument of both Metal paths in the catalogue (`tools/boot-args.py` reads `hm_boot_arg_set`)
- licenses: Turnip, AdrenoMetal, metal2vulkan and the plug-in's origin in `THIRD_PARTY_LICENSES.md`; a binary built with `M2V=1` has obligations and is **to verify** before any distribution
diff --git a/README.md b/README.md
index aae9509..07b8a2d 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ Android.
**Documentation:** [docs/](docs/index.md), and the site, [hackios-web.vercel.app](https://hackios-web.vercel.app).
**News, 4 November 2026:** on the POCO X5 Pro 5G the window server draws through Metal on the Adreno 642L, two ways. hakios-metal: page
-swipes 100 to 104 frames a second, Settings' scroll about 90, the home button about 90. UniXNU's Metal on Vulkan: swipes 50 to 57, scroll 41. The panel is 120 Hz,
+swipes 110 to 115 frames a second, Settings' scroll 118, the home button 106, rendering at 828x1792 stretched to the panel; 101, about 90 and about 90 at the full 1125x2436. UniXNU's Metal on Vulkan: swipes 50 to 57, scroll 41. The panel is 120 Hz,
and **120 frames a second has not been reached**. [Metal on the Adreno](docs/reference/metal.md),
[the measurements](docs/reference/metal-measurements.md).
diff --git a/README.uk.md b/README.uk.md
index 689d19d..c456041 100644
--- a/README.uk.md
+++ b/README.uk.md
@@ -10,7 +10,7 @@
**Документація:** [docs/](docs/index.md) (англійською) і сайт [hackios-web.vercel.app](https://hackios-web.vercel.app).
**Новини, 4 листопада 2026:** на POCO X5 Pro 5G віконний сервер малює через Metal на Adreno 642L, двома шляхами. hakios-metal: гортання
-сторінок 100–104 кадри на секунду, прокручування в Settings близько 90, кнопка «додому» близько 90. Metal поверх Vulkan від UniXNU: гортання 50–57, прокручування 41.
+сторінок 110–115 кадрів на секунду, прокручування в Settings 118, кнопка «додому» 106, рендер 828x1792, розтягнутий на панель; 101, близько 90 і близько 90 на повних 1125x2436. Metal поверх Vulkan від UniXNU: гортання 50–57, прокручування 41.
Панель працює на 120 Гц, і **120 кадрів на секунду не досягнуто**. [Metal на Adreno](docs/reference/metal.md),
[вимірювання](docs/reference/metal-measurements.md).
diff --git a/README.zh.md b/README.zh.md
index 075df98..3a78636 100644
--- a/README.zh.md
+++ b/README.zh.md
@@ -6,7 +6,7 @@
**文档:** [docs/](docs/index.md)(英文),以及网站 [hackios-web.vercel.app](https://hackios-web.vercel.app)。
-**动态,2026 年 11 月 4 日:** 在 POCO X5 Pro 5G 上,窗口服务器通过 Metal 在 Adreno 642L 上绘制,有两条路径。hakios-metal:翻页每秒 100 至 104 帧,Settings 滚动约 90 帧,主屏幕按钮约 90 帧。UniXNU 的 Metal on Vulkan:翻页 50 至 57 帧,滚动 41 帧。屏幕是 120 Hz,**尚未达到每秒 120 帧**。[Adreno 上的 Metal](docs/reference/metal.md),[测量结果](docs/reference/metal-measurements.md)。
+**动态,2026 年 11 月 4 日:** 在 POCO X5 Pro 5G 上,窗口服务器通过 Metal 在 Adreno 642L 上绘制,有两条路径。hakios-metal:翻页每秒 110 至 115 帧,Settings 滚动 118 帧,主屏幕按钮 106 帧(以 828x1792 渲染并拉伸到面板;完整 1125x2436 时为 101、约 90、约 90)。UniXNU 的 Metal on Vulkan:翻页 50 至 57 帧,滚动 41 帧。屏幕是 120 Hz,**尚未达到每秒 120 帧**。[Adreno 上的 Metal](docs/reference/metal.md),[测量结果](docs/reference/metal-measurements.md)。
从 [Getting started](docs/getting-started/index.md)、[On the phone](docs/getting-started/phone.md) 或 [Port a device](docs/porting/index.md) 开始。各部分的工作情况:[文档首页](docs/index.md#what-works)。
diff --git a/docs/reference/metal-measurements.md b/docs/reference/metal-measurements.md
index 7f64df1..273c3ea 100644
--- a/docs/reference/metal-measurements.md
+++ b/docs/reference/metal-measurements.md
@@ -41,6 +41,25 @@ the IOSurface with a compute pass. The linear attachment path (`VK_NV_linear_col
attachment that is not linear, and the extension wants every colour attachment linear. With `tu_debug=perf`, no barrier turned GMEM
off and no texture was shadowed.
+
+### The screen as the iPhone XR's (4 November)
+
+`fbwidth=828 fbheight=1792 fbscale=2 fbsubtype=1792`, the default of `tools/metal-run.sh`, stretched to the panel by the CPU. 1.85 times fewer
+pixels for the GPU; the picture is softer than at 1125x2436. The poster draws nothing on this screen: `wallpaper_freeze=1` shows the picture a
+boot at the iPhone X's screen kept in `/var/mobile/Library/hakios-wallpaper.raw`.
+
+| Gesture (`rc.jobs.bench.xr`) | Frames a second | At 1125x2436 |
+|---|---|---|
+| Settings' scroll | 118 | 89 to 91 |
+| Page swipe | 110 to 115 | 101 to 103 |
+| Home button | 106 | 89 to 92 |
+| Opening Settings | 86 | about 95 |
+| Frames over 16.7 ms | 1% | 4 to 6% |
+
+While something moves, half the frames are 8.33 ms apart and most of the rest one refresh more. What keeps the averages under 120: SpringBoard's main
+thread at the start of a gesture (36 to 57 ms) and of an application (104 ms), frames the GPU delivers a refresh late now and then, and the
+measured stretch ending in the slow ticks of a still screen. These are synthetic gestures (`rwtouch`).
+
## Tried, and it did not help
| What | Arguments | Result |
diff --git a/docs/reference/metal.md b/docs/reference/metal.md
index 6513645..489d6d1 100644
--- a/docs/reference/metal.md
+++ b/docs/reference/metal.md
@@ -5,7 +5,7 @@ measure it, and what is not known. The numbers: [Metal measurements](metal-measu
[the plan](../metal-plan.md).
**Status, POCO X5 Pro 5G, 3 and 4 November 2026.** Both paths draw the system correctly. hakios-metal is the faster: page swipes 100
-to 104 frames a second, Settings' scroll about 90, the home button about 90. metal2vulkan: swipes 50 to 57, scroll 41. **120 frames a second has not been
+to 104 frames a second, Settings' scroll about 90, the home button about 90 at the full 1125x2436; rendering at the iPhone XR's 828x1792, stretched to the panel (the default of `tools/metal-run.sh`), swipes 110 to 115, scroll 118, home button 106. metal2vulkan: swipes 50 to 57, scroll 41. **120 frames a second has not been
reached on either.** Neither is on by default: without `metal=1` the window server draws through OpenGL ES, as it always has.
diff --git a/tools/metal-run.sh b/tools/metal-run.sh
index 5d6698d..b9ed1cc 100755
--- a/tools/metal-run.sh
+++ b/tools/metal-run.sh
@@ -7,6 +7,7 @@
# MORE="metal_gmem=1" tools/... boot-args beside the ones below; one of the same name takes a default's place
# PERSIST=0 tools/metal-run.sh without var_store: /private/var starts empty and nothing is written to darwin
# UPLOAD=0 tools/metal-run.sh keep the system image already in the phone's RAM (default: upload this copy's)
+# (bench at this screen: RC_JOBS=rc.jobs.bench.xr, Settings lies lower; UPLOAD=0 keeps the image in the phone's RAM)
# SHOTS=N a screenshot every N seconds during the run into logs/<stamp>-shots/ (default 0)
# VERBOSE=1 tools/metal-run.sh with -v: the kernel's text console drawn over the picture (off by default: the log has it all)
#
@@ -31,6 +32,9 @@
# touch_poll_us=4000 the touch screen looked at every 4 ms, not 8: a sample in every refresh at 120 Hz
# wallpaper_freeze=1 the wallpaper one picture once at the home screen (the icons blink once): home button 28 -> 92 frames
# metal_defer=1 a command buffer's draws recorded when it is committed, not on the way
+# fbwidth=828 ... fbsubtype=1792 the iPhone XR's screen, 1.85 times fewer pixels, stretched to the panel: Settings' scroll 91 -> 118 frames,
+# swipes 101 -> 110-115, home button 90 -> 106. The poster draws nothing on it: wallpaper_freeze shows the
+# picture a boot at the iPhone X's screen kept: once, MORE="fbwidth=1125 fbheight=2436 fbscale=3 fbsubtype=0"
# a second (2 November, tools/frames.py)
# ufs=2 ufs_write=1 var_store=1 (PERSIST=1, the default) /private/var kept in the partition darwin between boots: the
# compiled shader stages in /var/db/hakios-metal-cache survive, so only the first boot
@@ -58,7 +62,7 @@ PERSIST=${PERSIST:-1}
UPLOAD=${UPLOAD:-1}
SHOTS=${SHOTS:-0}
CA_METALLIB=${CA_METALLIB:-/redwood/share/ca-share/QuartzCore-default.metallib}
-ARGS="gpu=1 metal=1 metal_fps=1 touch_lat=1 touchscreen=1 ca_metallib=$CA_METALLIB gpu_recover=1 anim_max=1 bootcpu=7 cpus=8 cpufreq=1 fb_hz=120 fb_measure=1 fb_threads=6 touch_poll_us=4000 wallpaper_freeze=1 metal_defer=1"
+ARGS="gpu=1 metal=1 metal_fps=1 touch_lat=1 touchscreen=1 ca_metallib=$CA_METALLIB gpu_recover=1 anim_max=1 bootcpu=7 cpus=8 cpufreq=1 fb_hz=120 fb_measure=1 fb_threads=6 touch_poll_us=4000 wallpaper_freeze=1 metal_defer=1 fbwidth=828 fbheight=1792 fbscale=2 fbsubtype=1792"
[ "$PERSIST" = 1 ] && ARGS="$ARGS ufs=2 ufs_write=1 var_store=1"
[ "${VERBOSE:-0}" = 1 ] && ARGS="-v $ARGS"
# (a default of the same name goes: the kernel takes the last of two, the plug-in and SpringBoard the first)
diff --git a/userland/rc.jobs.bench.xr b/userland/rc.jobs.bench.xr
new file mode 100644
index 0000000..2193c97
--- /dev/null
+++ b/userland/rc.jobs.bench.xr
@@ -0,0 +1,12 @@
+# Commands run by the launchd job com.hakios.demo (see com.hakios.demo.plist).
+# The frame-rate benchmark at the iPhone XR's screen (Settings lies lower there; RC_JOBS=rc.jobs.bench.xr, touch_lat=1, SECS=180; tools/frames.py): unlock, a minute for the
+# start-up work to be over (src/cputop.c beside it says whether it was; the home screen's layout is the same in every
+# boot once the widgets are up), then four times the same round -- Settings opened from its icon, its list scrolled,
+# the home button, a page swipe there and back -- so that each kind of motion is measured four times in the same state
+# of the system and runs can be compared.
+/redwood/bin/cputop 5 &
+/redwood/bin/rwtouch wait 30 swipe 0.5 0.985 0.5 0.3 200 wait 60
+/redwood/bin/rwtouch tap 0.615 0.80 wait 3 zigzag 0.5 0.75 0.35 500 3 wait 2 button home wait 3 swipe 0.85 0.5 0.15 0.5 300 wait 1 swipe 0.15 0.5 0.85 0.5 300 wait 2
+/redwood/bin/rwtouch tap 0.615 0.80 wait 3 zigzag 0.5 0.75 0.35 500 3 wait 2 button home wait 3 swipe 0.85 0.5 0.15 0.5 300 wait 1 swipe 0.15 0.5 0.85 0.5 300 wait 2
+/redwood/bin/rwtouch tap 0.615 0.80 wait 3 zigzag 0.5 0.75 0.35 500 3 wait 2 button home wait 3 swipe 0.85 0.5 0.15 0.5 300 wait 1 swipe 0.15 0.5 0.85 0.5 300 wait 2
+/redwood/bin/rwtouch tap 0.615 0.80 wait 3 zigzag 0.5 0.75 0.35 500 3 wait 2 button home wait 3 swipe 0.85 0.5 0.15 0.5 300 wait 1 swipe 0.15 0.5 0.85 0.5 300 wait 2
diff --git a/userland/src/inject_sb.c b/userland/src/inject_sb.c
index b8bd496..fc85f64 100644
--- a/userland/src/inject_sb.c
+++ b/userland/src/inject_sb.c
@@ -938,6 +938,83 @@ wallpaper_window(void)
return NULL;
}
+/*
+ * The picture is kept in /private/var (var_store keeps that across boots), for a screen of another class (fbscale=2
+ * fbsubtype=1792: 1.85 times fewer pixels for the GPU), on which the poster draws nothing at all: black.
+ */
+#define WALLPAPER_KEPT "/var/mobile/Library/hakios-wallpaper.raw"
+struct wallpaper_kept { uint32_t magic, width, height, row; };
+#define WALLPAPER_MAGIC 0x57504b31
+
+static void
+wallpaper_keep(const uint8_t *pixels, size_t width, size_t height, size_t row)
+{
+ struct wallpaper_kept head = { WALLPAPER_MAGIC, (uint32_t)width, (uint32_t)height, (uint32_t)row };
+ int fd = open(WALLPAPER_KEPT ".new", O_WRONLY | O_CREAT | O_TRUNC, 0644);
+
+ if (fd < 0) {
+ say("hakios: SpringBoard: wallpaper_freeze: %s cannot be written\n", WALLPAPER_KEPT);
+ return;
+ }
+ bool whole = write(fd, &head, sizeof(head)) == (ssize_t)sizeof(head) &&
+ write(fd, pixels, row * height) == (ssize_t)(row * height);
+ close(fd);
+ if (whole) {
+ rename(WALLPAPER_KEPT ".new", WALLPAPER_KEPT);
+ say("hakios: SpringBoard: wallpaper_freeze: the picture kept, %zux%zu\n", width, height);
+ }
+}
+
+/* The picture kept, redrawn at this screen's pixels (a texture of the screen's own size to sample); NULL: none. */
+static id
+wallpaper_kept_picture(double width_points, double height_points, double scale)
+{
+ struct wallpaper_kept head;
+ int fd = open(WALLPAPER_KEPT, O_RDONLY);
+ id image = NULL;
+
+ if (fd < 0) {
+ return NULL;
+ }
+ if (read(fd, &head, sizeof(head)) == (ssize_t)sizeof(head) && head.magic == WALLPAPER_MAGIC && head.width != 0 && head.height != 0 &&
+ head.row >= head.width * 4 && head.height < 16384) {
+ size_t bytes = (size_t)head.row * head.height;
+ uint8_t *pixels = malloc(bytes);
+
+ if (pixels != NULL && read(fd, pixels, bytes) == (ssize_t)bytes) {
+ size_t w = (size_t)(width_points * scale + 0.5), h = (size_t)(height_points * scale + 0.5);
+ CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
+ CGBitmapInfo info = kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst;
+ CFDataRef data = CFDataCreateWithBytesNoCopy(NULL, pixels, bytes, kCFAllocatorNull);
+ CGDataProviderRef provider = CGDataProviderCreateWithCFData(data);
+ CGImageRef kept = CGImageCreate(head.width, head.height, 8, 32, head.row, space, info, provider, NULL, false, kCGRenderingIntentDefault);
+ CGContextRef context = CGBitmapContextCreate(NULL, w, h, 8, 0, space, info);
+
+ if (kept != NULL && context != NULL) {
+ CGContextSetInterpolationQuality(context, kCGInterpolationHigh);
+ CGContextDrawImage(context, CGRectMake(0, 0, (CGFloat)w, (CGFloat)h), kept);
+ CGImageRef made = CGBitmapContextCreateImage(context);
+
+ if (made != NULL) {
+ image = ((id (*)(id, SEL, CGImageRef, double, long))objc_msgSend)((id)objc_getClass("UIImage"),
+ sel_registerName("imageWithCGImage:scale:orientation:"), made, scale, 0L);
+ CGImageRelease(made);
+ }
+ }
+ say("hakios: SpringBoard: wallpaper_freeze: the picture kept (%ux%u) drawn at %zux%zu: %s\n", head.width, head.height, w, h,
+ image != NULL ? "yes" : "NO");
+ if (context != NULL) CGContextRelease(context);
+ if (kept != NULL) CGImageRelease(kept);
+ CGDataProviderRelease(provider);
+ CFRelease(data);
+ CGColorSpaceRelease(space);
+ }
+ free(pixels);
+ }
+ close(fd);
+ return image;
+}
+
/* A picture of the surface on the panel, opaque, in points of the screen's scale; NULL: none, or all one colour. */
static id
wallpaper_picture(double scale)
@@ -969,6 +1046,7 @@ wallpaper_picture(double scale)
say("hakios: SpringBoard: wallpaper_freeze=1: surface %u, %zux%zu, %zu bytes a row, format %#x: %u of 97 samples unlike the first (%#x)\n",
sid, width, height, row, IOSurfaceGetPixelFormat(surface), distinct, pixels != NULL ? *(const uint32_t *)CFDataGetBytePtr(pixels) : 0);
if (pixels != NULL && distinct >= 10) {
+ wallpaper_keep(CFDataGetBytePtr(pixels), width, height, row);
CGDataProviderRef provider = CGDataProviderCreateWithCFData(pixels);
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
CGImageRef cg = CGImageCreate(width, height, 8, 32, row, space, kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipFirst,
@@ -1058,6 +1136,21 @@ wallpaper_freeze_pass(unsigned attempt)
wallpaper_put(window, NULL);
return;
}
+ /* a screen of another class than the iPhone X's: no poster to read off the panel, the picture kept instead */
+ {
+ hk_rect bounds = ((hk_rect (*)(id, SEL))objc_msgSend)(window, sel_registerName("bounds"));
+
+ if (bounds.width != 375 || bounds.height != 812) {
+ id image = wallpaper_kept_picture(bounds.width, bounds.height, scale);
+
+ if (image != NULL) {
+ wallpaper_put(window, image);
+ } else {
+ say("hakios: SpringBoard: wallpaper_freeze: no picture kept for this screen: a boot at the iPhone X's first\n");
+ }
+ return;
+ }
+ }
/* the icons out of the way until the window server has drawn the wallpaper without them */
id app = SEND(id, objc_getClass("UIApplication"), "sharedApplication");
id windows = SEND(id, app, "windows");