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

mkhighrate.py: CADisableMinimumFrameDurationOnPhone in every application of the system image; without it CoreAnimation held each process to 60 a second on the 120 Hz panel

shimoku74c7b5f9a88818
diff --git a/userland/build.sh b/userland/build.sh
index 35111cc..f022c32 100755
--- a/userland/build.sh
+++ b/userland/build.sh
@@ -583,6 +583,10 @@ if [ -f $DARWIN/system.manifest ] && [ -f $CACHE/dyld_shared_cache_arm64 ] &&
fi
mv sysroot/sbin/launchd sysroot/sbin/launchd.darwin
cp obj/stage0 sysroot/sbin/launchd
+ # the applications' frame rate: on a phone CoreAnimation holds every process to 60 frames a second unless its
+ # bundle says CADisableMinimumFrameDurationOnPhone, which no application of an iPhone X's system does; the panel
+ # here runs at 120 (IOMFBDisplayRefresh, MiniIOMobileFramebuffer.cpp). New files, not edits: sysroot's are links
+ python3 mkhighrate.py sysroot
# the audio DSP's firmware, the phone's own from ../fw-audio (never in the repository), where the kernel reads
# it once the root is mounted (drivers/audio/hakios.adsp.c, adsp=1): 20 MB that do not fit beside GL=1 in the small image
if [ -f ../fw-audio/adsp.mdt ]; then
diff --git a/userland/mkhighrate.py b/userland/mkhighrate.py
new file mode 100644
index 0000000..b70e686
--- /dev/null
+++ b/userland/mkhighrate.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python3
+"""
+mkhighrate.py SYSROOT: CADisableMinimumFrameDurationOnPhone = YES in the Info.plist of every application of the system
+image being made (SpringBoard, /Applications, /System/Library/CoreServices).
+
+On a phone CoreAnimation keeps a process's frames at most 60 a second unless its bundle has that key (QuartzCore reads
+it; the iPhones with a 120 Hz panel ship their applications with it). Without it the home screen and every application
+ran at 60 on this 120 Hz panel even once CoreAnimation knew the panel's rate (fps_info: maximumFramesPerSecond 120;
+tools/frames.py: frames every 16.9 ms, 30 October).
+
+SYSROOT is hard links (or clones) of sysimage/rootfs: a plist is written as a new file in place of the link, never
+into it, so the extracted system stays as it came out of the IPSW.
+"""
+import glob
+import os
+import plistlib
+import sys
+
+KEY = 'CADisableMinimumFrameDurationOnPhone'
+
+root = sys.argv[1]
+changed = already = 0
+for path in sorted(glob.glob(os.path.join(root, 'Applications', '*.app', 'Info.plist')) +
+ glob.glob(os.path.join(root, 'System', 'Library', 'CoreServices', '*.app', 'Info.plist'))):
+ with open(path, 'rb') as f:
+ data = f.read()
+ info = plistlib.loads(data)
+ if info.get(KEY) is True:
+ already += 1
+ continue
+ info[KEY] = True
+ binary = data.startswith(b'bplist')
+ mode = os.stat(path).st_mode & 0o7777
+ os.unlink(path) # the link goes; the original stays as it was
+ with open(path, 'wb') as f:
+ plistlib.dump(info, f, fmt=plistlib.FMT_BINARY if binary else plistlib.FMT_XML)
+ os.chmod(path, mode)
+ changed += 1
+print(f'mkhighrate.py: {KEY} set in {changed} applications ({already} had it already)')