Skip to content

ntsync: runtime kernel/userspace backend detection - #38

Merged
joshuatam merged 2 commits into
proton_11.0-2from
update/proton-11.0-2-ntsync-detection
Aug 31, 2026
Merged

ntsync: runtime kernel/userspace backend detection#38
joshuatam merged 2 commits into
proton_11.0-2from
update/proton-11.0-2-ntsync-detection

Conversation

@joshuatam

@joshuatam joshuatam commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

Replaces the compile-time #ifdef __ANDROID__ all-or-nothing userspace-ntsync selection with runtime backend detection:

  • wineserver opens /dev/ntsync and probes it with a real NTSYNC_IOC_CREATE_EVENT ioctl at startup (catches SELinux/seccomp-blocked nodes that are openable but unusable)
  • Kernel driver present and usable → use it directly
  • Otherwise → fall back to the userspace ntsync-android shm backend
  • PROTON_NO_NTSYNC=1 still disables both backends
  • Backend is chosen once per session and propagated to all clients via the existing init_first_thread reply (NTSYNC_ANDROID_USED_BY_SERVER sentinel)

Changes

  • New android/ntsync_android/ntsync_kernel_abi.h — frozen kernel uapi ioctl numbers, pairs with ntsync_user.h (whose structs clash with ntsync_tmp.h, so both cannot be included in one TU)
  • server_inproc_sync_c.patch — runtime get_inproc_device_fd() with kernel probe + userspace fallback; all call sites dispatch on a ntsync_userspace flag
  • dlls_ntdll_unix_sync_c.patch — both linux_* (ioctl) and userspace_* (libntsync_android) paths compiled in, per-call dispatch
  • server_thread_c / server_process_c / dlls_ntdll_unix_server_c / dlls_ntdll_unix_unix_private_h patches — matching runtime branches; ntsync_sweep_dead() now gated on userspace active (no ~960 KB shm region init on kernel-ntsync devices)
  • android/ntsync_android/README.md — documents runtime backend selection order
  • build-proton.yml — release notes updated; ntsync-android library pinned unchanged at 7ce6435

No ntsync-android library changes; no build-script changes (same patch filenames).

Verification

  • Full 56-patch train applies cleanly in build-script order on pristine proton_11.0-2 HEAD (worktree-tested)
  • Android arm64ec build: server/wineserver and dlls/ntdll/ntdll.so compile and link with -lntsync_android — zero new warnings
  • Non-Android path: -fsyntax-only -U__ANDROID__ -Werror passes on all touched files (non-Android builds compile identical to upstream)

Test plan

  • On-device gameplay test with NTSYNC_DEBUG=1 — expect log line ntsync: no usable /dev/ntsync, using userspace ntsync. on devices without the kernel driver
  • Device with a kernel /dev/ntsync (custom kernel) — expect ntsync: up and running. and no shm region created

…-time #ifdef

Replace the hardcoded __ANDROID__ userspace-ntsync selection with runtime
detection: wineserver opens /dev/ntsync and probes it with a real
NTSYNC_IOC_CREATE_EVENT ioctl (catches SELinux/seccomp-blocked nodes);
if the device is missing or unusable it falls back to the userspace
libntsync_android shm backend. PROTON_NO_NTSYNC=1 still disables both.

- add android/ntsync_android/ntsync_kernel_abi.h: frozen kernel uapi
  ioctl numbers, pairs with ntsync_user.h (whose structs clash with
  ntsync_tmp.h, so both cannot be included together)
- server/inproc_sync.c: runtime get_inproc_device_fd() with kernel
  probe + userspace fallback; all call sites dispatch on ntsync_userspace
- dlls/ntdll/unix/sync.c: compile both linux_* and userspace_* paths,
  dispatch per call; client learns backend via init_first_thread reply
- server/thread.c, process.c, ntdll/unix/server.c, unix_private.h:
  matching runtime branches; ntsync_sweep_dead gated on userspace active
  (no shm region auto-init in kernel mode)
- README: document runtime backend selection order

Verified: full 56-patch train applies on pristine HEAD; Android arm64ec
builds of server/wineserver and dlls/ntdll/ntdll.so link with zero new
warnings; non-Android path passes -fsyntax-only -Werror.
Release notes now describe runtime backend selection (kernel /dev/ntsync
probe at wineserver startup, userspace ntsync-android fallback,
PROTON_NO_NTSYNC=1 to disable) instead of the old compile-time userspace
selection. ntsync-android library pinned unchanged at 7ce6435; the
accumulated changelog is replaced with just this build's changes.
App-facing descriptions updated to match.
@joshuatam
joshuatam merged commit d67ac1e into proton_11.0-2 Aug 31, 2026
3 checks passed
@joshuatam
joshuatam deleted the update/proton-11.0-2-ntsync-detection branch August 31, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant