Skip to content

Commit b6d71c9

Browse files
committed
Preload system SDL2 to use muOS mali driver
pygame-ce's PyPI wheel bundles a headless SDL2 that only has the offscreen/dummy video drivers. On muOS devices, this results in an invisible app — pygame renders to memory, the framebuffer never updates, and users are stuck on the muOS "Loading Application" splash. muOS devices ship their own SDL2 2.28.5 at /usr/lib/libSDL2-2.0.so.0 with a custom mali video driver for the Mali GPU. On some setups (e.g. RG35XXH) a SETUP_APP hook LD_PRELOADs libmustage.so which pulls in this system SDL2, making it work by accident. On others (RG35XX Pro, RG40XXH) libmustage.so is missing, so the bundled headless SDL2 gets used and the screen stays blank. Fix: explicitly LD_PRELOAD /usr/lib/libSDL2-2.0.so.0 from the launch script when present. pygame then uses muOS's mali-capable SDL2 regardless of libmustage.so availability. Also bundles libdrm.so.2/libgbm.so.1 (belt-and-braces — if a device ever needs kmsdrm instead of mali, SDL can dlopen them from the PyInstaller temp dir) and logs the active SDL video driver at startup to make future display issues easier to diagnose. Bumps version to 4.0.5. Fixes #53 — confirmed on RG35XXH, RG35XX Pro, and RG40XXH.
1 parent 312a0f7 commit b6d71c9

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎app.spec‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
a = Analysis(
55
['src/app.py'],
66
pathex=[],
7-
binaries=[],
7+
binaries=[
8+
# Bundle libdrm/libgbm so SDL2's dynamically-loaded kmsdrm driver
9+
# can find them inside PyInstaller's temp extraction dir. Without
10+
# these, SDL2 falls back to the offscreen driver on muOS devices
11+
# that don't expose libdrm via a standard library path.
12+
('/usr/lib/aarch64-linux-gnu/libdrm.so.2', '.'),
13+
('/usr/lib/aarch64-linux-gnu/libgbm.so.1', '.'),
14+
],
815
datas=[],
916
hiddenimports=[],
1017
hookspath=[],

‎mux_launch.sh‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ export XDG_DATA_HOME="$STATICDIR"
3333
export HOME="$STATICDIR"
3434
export LD_LIBRARY_PATH="$BINDIR/libs.aarch64:$LD_LIBRARY_PATH"
3535

36+
# Force pygame to use muOS's system SDL2 (which has the 'mali' video driver)
37+
# instead of pygame-ce's bundled headless copy (dummy/offscreen only).
38+
# On muOS setups with libmustage.so this already happens via SETUP_APP's
39+
# LD_PRELOAD; on setups without it (e.g. some RG40XXH firmwares) we have
40+
# to do it ourselves.
41+
SYSTEM_SDL2="/usr/lib/libSDL2-2.0.so.0"
42+
if [ -f "$SYSTEM_SDL2" ]; then
43+
export LD_PRELOAD="$SYSTEM_SDL2:$LD_PRELOAD"
44+
fi
45+
3646
# Launcher
3747
cd "$ARTIE_DIR" || exit
3848

‎src/app.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from settings import SettingsScreen, SystemSelectionScreen, VirtualKeyboard
4040
from updater import check_for_update, download_and_apply_update
4141

42-
VERSION = "4.0.4"
42+
VERSION = "4.0.5"
4343

4444

4545
class _ScrapeCancelledError(Exception):

‎src/graphic.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ def draw_start(self, display_width: int = 0, display_height: int = 0):
151151
pygame.mouse.set_visible(False)
152152
# Enable key repeat for smooth hold-to-scroll (400ms delay, 80ms interval)
153153
pygame.key.set_repeat(400, 80)
154+
driver = pygame.display.get_driver()
154155
logger.log_info(
155156
f"Pygame display initialized: {dw}x{dh} "
156-
f"(internal {SCREEN_WIDTH}x{SCREEN_HEIGHT})"
157+
f"(internal {SCREEN_WIDTH}x{SCREEN_HEIGHT}, driver={driver})"
157158
)
158159
except (pygame.error, OSError) as e:
159160
logger.log_warning(f"Display initialization failed: {e}")

0 commit comments

Comments
 (0)