Skip to content

Recover controller haptics after helper initialization failures - #143

Closed
nanda86 wants to merge 1 commit into
seedds:mainfrom
nanda86:fix/controller-haptics-initialization
Closed

nanda86 wants to merge 1 commit into
seedds:mainfrom
nanda86:fix/controller-haptics-initialization

Conversation

@nanda86

@nanda86 nanda86 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Controller rumble can remain silent after a Core Haptics helper fails to initialize: the adapter retries the same failed engine indefinitely, and startup happens before reset/stop handlers are installed. This was observed with a Bluetooth Switch Pro controller that vibrates through iOS Settings Identify, while the game logs Core Haptics -4810.

Create engines on demand, attach lifecycle handlers before starting, and discard failed connections. Fresh game signals retry with a new engine after a 1–8 second backoff; old effects and callbacks cannot reach the replacement. If separate controller handle engines fail, fall back to the default controller locality. Phone engine creation is deferred until the game's audio session is active. Errors now include the stage, target, domain/code and underlying service error.

Validation:

  • Reproduced the original stuck-engine behavior with a permanently failing fake controller engine.
  • Full host unit suite passed: make -C dm/host/tests GAME=0100DCA0064A6000 -j3 run (normal host audio access).
  • Adapter regression tests cover creation/start/player/parameter failures, retry throttling, default-locality fallback and stale callbacks, alongside existing pulse, idle and separate-channel checks.
  • iOS arm64 syntax check with -Wall -Werror passed.
  • The signed iPhone Debug app built successfully. Existing UIRequiresFullScreen deprecation and skipped App Intents metadata warnings remain; no new compiler warnings were introduced.
  • Physical controller confirmation is pending; this PR stays draft until that check. Hosted CI is requested because this changes asynchronous engine lifecycle handling.

No game files, keys, provisioning material or device logs are included.

seedds added a commit that referenced this pull request Oct 25, 2026
…etried for good (general, from PR #143). A Bluetooth Switch Pro controller that vibrates through iOS Settings' Identify stayed silent in a game, which logged Core Haptics -4810 (server init failed): the adapter made each engine once per route and called startAndReturnError on that same broken engine at every later effect, and its stop/reset handlers were installed only after the start. Now haptics_apple.m makes an engine when the first effect needs it (the phone's too, so after the audio session is active), installs the handlers before starting it, and a failure to make or start the engine, make or start its player or send its parameters releases that engine: a fresh game signal makes a new one after a backoff of 1, 2, 4 or 8 s, effects from before the failure are not replayed, and the old engine's callbacks are stale (generation). A controller whose left and right handle engines cannot be made or started falls back to its default locality until it reconnects; a player or parameter failure (a service reset, say) is retried on the same handle. Idle release (1 s of silence), focus loss and engine resets stop an engine but keep it, so the next effect restarts the same engine, as before. Errors name the target, the stage, the error domain and code and the underlying error, and the log names the controller, its localities and the output channels. From PR #143 (nanda86), with two changes: the PR dropped the engine at every stop, so each rumble after a second of silence made a new engine (a new connection to the haptics service on a controller, a new initWithAudioSession: engine on the phone), and any handle failure moved the route to the default locality for good. t_haptics_apple covers each failure stage, the backoff, the fallback (and no fallback on a player failure), stale callbacks, a restarted engine after idle release, a disconnect and a controller without haptics, with fake controllers and engines. Checked: the host unit tests pass (GAME=0100DCA0064A6000), haptics_apple.m compiles for iOS arm64 with -Wall -Werror. Not checked: a physical controller or the iPhone's own haptics
@seedds

seedds commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Thank you for this, and for the clear write-up and the tests. It's in main as 0f99c35, credited to this PR, with two changes:

  • The engine is now kept when it only stops (idle release after 1 s of silence, focus loss, a service reset), so the next effect restarts the same engine. With the engine dropped at every stop, each rumble after a pause made a new engine: a new connection to the haptics service on a controller, a new initWithAudioSession: engine on the phone. Only a failure releases the engine now.
  • The fallback to the default locality now happens only when a handle engine can't be created or started. A player or "send parameters" failure (a service reset, say) is retried on the same handle instead of combining the route until the controller reconnects.

t_haptics_apple has a case for each change. The host unit tests pass, and the adapter compiles for iOS arm64 with -Wall -Werror. A check with your Pro controller on current main would still be very welcome.

@seedds seedds closed this Oct 25, 2026
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…etried for good (general, from PR seedds#143). A Bluetooth Switch Pro controller that vibrates through iOS Settings' Identify stayed silent in a game, which logged Core Haptics -4810 (server init failed): the adapter made each engine once per route and called startAndReturnError on that same broken engine at every later effect, and its stop/reset handlers were installed only after the start. Now haptics_apple.m makes an engine when the first effect needs it (the phone's too, so after the audio session is active), installs the handlers before starting it, and a failure to make or start the engine, make or start its player or send its parameters releases that engine: a fresh game signal makes a new one after a backoff of 1, 2, 4 or 8 s, effects from before the failure are not replayed, and the old engine's callbacks are stale (generation). A controller whose left and right handle engines cannot be made or started falls back to its default locality until it reconnects; a player or parameter failure (a service reset, say) is retried on the same handle. Idle release (1 s of silence), focus loss and engine resets stop an engine but keep it, so the next effect restarts the same engine, as before. Errors name the target, the stage, the error domain and code and the underlying error, and the log names the controller, its localities and the output channels. From PR seedds#143 (nanda86), with two changes: the PR dropped the engine at every stop, so each rumble after a second of silence made a new engine (a new connection to the haptics service on a controller, a new initWithAudioSession: engine on the phone), and any handle failure moved the route to the default locality for good. t_haptics_apple covers each failure stage, the backoff, the fallback (and no fallback on a player failure), stale callbacks, a restarted engine after idle release, a disconnect and a controller without haptics, with fake controllers and engines. Checked: the host unit tests pass (GAME=0100DCA0064A6000), haptics_apple.m compiles for iOS arm64 with -Wall -Werror. Not checked: a physical controller or the iPhone's own haptics
ltrdpper pushed a commit to ltrdpper/BananaNative that referenced this pull request Nov 11, 2026
…ix, 12 GB memory, foldable inner screen, Pokopia frame cap

Memory maps (seedds#127, seedds#132): background pipeline compiles on Turnip are serialized (vk-psoasync / vk-psopt through the heavy-compile hold), contiguous placed segments are joined across pools at submission start, unplace copies through sw_mmap_fixed instead of mremap so the kernel merges anonymous VMAs again, and past 2,000 split anonymous maps the dirty tracker releases its protections once (one re-upload) so guest VMAs merge.
Launcher: android:appCategory="game" (seedds#110); the game fills a foldable's near-square inner screen (GameOrientation.fixedLandscape from the maximum window metrics); overlay blocks inset from rounded corners and cutouts (seedds#105, OverlayInset); Prepare texts say whether the code rewrite or a shader translation runs and that shaders are kept; no "Ready, with limits" dialog at start.
Frame rate: Ocarina of Time (`0400486024DEC000`) fps_limit 60 (was 30). Pokémon Pokopia (`0400A3A01EE4C000`) fps_limit 60 with the new launcher key fps_limit_present: the host limiter's caps are offered with a note that they pace the presents only (seedds#143).
Skipped work: the Vulkan replay counts draws and dispatches skipped for causes of the device (no mesh shading, refused shaders or pipelines, missing features) and warns once per run past DM_VK_SKIP_WARN percent (default 5) in two 300-frame windows in a row; the launcher shows a small notice.
Textures: the pool-read line counts images made again for an ID made before (diagnostic, seedds#131).
Docs: Fire Emblem Fortune's Weave's note links only existing reference entries; docs_patches classifies av1_decoder.
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.

2 participants