Repository navigation
perf: skip the web-haptics engine on desktop browsers without vibration - #45
Merged
Merged
Conversation
joeblau
force-pushed
the
perf/37-skip-engine-without-vibration
branch
from
October 21, 2026 01:03
2d104a0 to
2856cb1
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #37
What
When a target is tapped,
requestFeedbacknow returns before it creates or triggers aWebHapticsengine if all of these hold:typeof navigator.vibrate !== 'function', checked at tap time rather than through the module-loadWebHaptics.isSupported.webHapticsOptions.debugisn't set.webHapticsOptions.showSwitchisn't set.On desktop browsers without vibration, the engine's hidden
<label>+<input switch>and its rAF pattern loop produced no feedback. The vibration path and the iOS native path are unchanged. Debug audio and the visible switch work exactly as before.Tests:
beforeEachnow stubsnavigator.vibrate. The existing engine tests ran without a stub, so they now exercise the vibration path they assert on.unsupported desktopsuite:debug: false/showSwitch: false, no engine is created, no trigger fires and no body nodes are added, and the host action still fires once.debug: trueand withshowSwitch: true, the engine is still constructed and triggered.Implemented with the Codex CLI on the shared box and verified by hand.
Benchmark (
npm run bench, same box)The desktop-without-vibration path wasn't touched by #42, #43 or #44, so the quieter
78ec2f2runs from earlier today are a valid baseline. "Interleaved" means back-to-back runs onmainat1ea44a1while another agent's build was saturating the box.The vibration and iOS rows show no change beyond noise; vibration engines stay at 100 and iOS engines at 0. Full ESM goes from 4,583 to 4,607 gzip bytes (+24 B).
Verification
npm run lint,typecheck(ESM+CJS+DTS build),coverage(146 tests, 100% statements/branches/functions/lines on React 19 and React 18.3.1),size, andpack:checkall pass.navigatoris guaranteed there, and nothing reads it at import or during server render.isIOSWebKitWithoutVibration()misses would lose the hidden-switch fallback. Detection already covers iPhone/iPad/iPod and iPadOS desktop mode (MacIntel+ touch points). In-app webviews still need physical confirmation in Certify iOS and Android behavior on physical devices #9.Device-testing notes
These are simulated-browser numbers from Node 24 with production React and jsdom, using a stubbed Linux
navigatorwith novibrate. None were measured on physical devices, and no physical device was used. Physical iPhone/Android/iPadOS/VoiceOver certification is still tracked in #9.