Games
How often does onHingeChange update? Sparsely, and only on change
On the iPhone Duo simulator, onHingeChange updates roughly 5 to 20 times a second, only when the angle changes, often jumping 10 to 30 degrees at once. UIKit’s hinge interaction gets the same events, and no setting makes either one faster. Creaky Hinge, a door that creaks as you fold the phone, needed its own speed estimate, predicted angle and silence timer to cope. Knowing this up front saves you designing around a smooth stream that never arrives.
How often does onHingeChange actually fire?
It fires when the hinge angle changes, and at no fixed rate. Apple’s header for the hinge API calls the rate system policy. On the iPhone Duo simulator in Xcode 27.1, that policy delivered roughly 5 to 20 events a second. Consecutive events were often 10 to 30 degrees apart.
Each event carries an angle and a fold status: closed, fully open, or somewhere between. Creaky Hinge reads only those two and works out everything else itself, starting with when the event arrived.
UIKit’s hinge interaction is not a faster way in. On the simulator it delivered identical events, with SwiftUI’s arriving about 3 ms later. The 27.1 SDK has no rate setting, and Core Motion has no hinge equivalent. Whatever your effect needs, these events are all you get.
To see your own numbers, stamp each event with your own clock as it arrives and log the gap since the previous one. Creaky Hinge’s debug build logs every hinge event with that gap. Repeat the check after an OS update, because a policy can change without the API changing.
Why does a stopped hinge never send an event?
Because onHingeChange fires only on change, and a hinge at rest has nothing left to change. It reports the hinge’s state once, then on each change. When you stop folding, the stream goes quiet. No event ever says the speed is now zero.
That matters for anything driven by speed. If your effect only runs inside the callback, it keeps the last speed it heard. A creak that should stop would keep playing until the next fold.
The fix is a clock of your own. Creaky Hinge polls its speed estimate on a timer that ticks about 60 times a second. When no event has arrived for about two and a half typical gaps, the estimate drops to zero. That window is clamped between 60 ms and 350 ms. A quick stream goes silent quickly, and even a slow one goes silent within about a third of a second.
The timer is not the only trigger. Each hinge event also forces an immediate update, so the sound answers an event at once instead of on the next tick.
How do you turn sparse angles into a speed?
Take the angle change between two events and divide it by the time between them, measured on your own clock. Creaky Hinge also keeps a running average of the gap between events. That average is the “typical gap” the silence timer counts in.
The estimate is smoothed with a 20 ms time constant. At the rates the simulator delivers, every gap is longer than that, so in practice each new event sets the speed outright. The smoothing only starts to matter if events arrive faster than 50 a second.
The first event after a rest needs its own rule. The gap since the previous event may be seconds long, and dividing by it would read a quick flick as almost no movement. So when the gap is longer than 350 ms, the app divides the movement by the typical gap instead. The first move after a pause registers as movement straight away.
Should you interpolate between hinge events or predict ahead?
Predict ahead. Interpolating between two events means waiting for the second one, which puts your animation a whole event gap behind the hinge. At 5 to 20 events a second on the simulator, that gap is 50 to 200 ms. That is a long time for a picture that should move with your hand.
Creaky Hinge’s door extrapolates instead. After each event it keeps moving at the measured speed for one expected gap. If no event arrives by then, it gives that lead back over the following gap. A door that guessed wrong drifts back to the last reported angle rather than sailing on.
When the next event lands, the difference between the guess and the reported angle shrinks with a 60 ms time constant. The door eases onto the new angle instead of snapping to it.
The sound does not predict. It reacts to each event as it arrives, which is why the immediate update on every event matters.
How does a hinge speed become a creak?
Map speed to volume and pitch, then ramp both. Creaky Hinge’s curve follows the approach of LidAngleSensor, an open-source creaker for a MacBook’s lid angle.
The door is silent below 2 degrees a second, so a tiny wobble stays quiet. From there up to 30 degrees a second it plays at full volume. Above 30 it fades on a smooth curve and is silent by 300 degrees a second. Playback rate rises in a straight line with speed, from 0.8 at rest to 1.1 at 300 degrees a second. A slow fold is loud and low, and a fast one is quiet and higher.
Ramps stop a jump from clicking. Volume rises with a 12 ms time constant and falls with a 60 ms one. Pitch glides with a 40 ms one. While the creak fades to silence, its pitch holds still, so a stopping fold does not slide upward as it dies away.
All of that sits on top of the delay every phone adds between asking for a sound and playing it. Creaky Hinge asks the audio session for a 5 ms buffer to keep that delay short. If you have not met output latency before, the rhythm-game version of the problem shows where that delay comes from.
What does the creak do with these three hinge logs?
A slow fold creaks loud and low, a sudden jump goes silent, and a hinge that has stopped goes silent on the app’s own timer. The three logs below show each case as time and angle. They are made up to show the rules above, not recorded from a device.
- A slow, steady fold. 0 ms at 40°, 100 ms at 43°, 200 ms at 46°. That is 30 degrees a second, so the creak plays at full volume with its pitch near the bottom of its range. You hear it loud and low.
- A jump mid-fold. An event at 90°, then one at 120° 50 ms later. That is 600 degrees a second, twice the speed where the creak goes silent. The creak drops away, and that is the speed estimate doing its job.
- A last event 400 ms ago. Nothing has arrived since. The creak is silent, but no event said so. 400 ms is past the longest silence window of 350 ms, so the app’s own timer set the speed to zero.
Which of the three logs is silent only because the app's own timer decided so?
Answer: The last event 400 ms ago, nothing since — Right. No event will ever report zero speed. 400 ms is past the 350 ms silence window, so the app's own timer set the speed to zero.
How do you test a hinge without the phone?
Use the iPhone Duo simulator in Xcode 27.1. That release has no separate Simulator app: the device runs inside Xcode, and its hinge slider sits in Device Hub, hidden until you hold Option.
Folding it from a script is harder. Creaky Hinge’s screenshot runs post the same private, undocumented event the slider sends, through a small open-source helper. Because nothing documents that event, it can break with any Xcode update. The run therefore checks which display came on after each fold and fails if the fold did not take.
A phone with no hinge needs its own test. On such a phone onHingeChange is never called, because there is no hinge state to change. Waiting for a nil report waits forever. Creaky Hinge waits one second after it becomes active. If no hinge has reported by then, it lets you drag the door with a finger, and a late hinge report still takes over. Its drag mode was checked by hand on regular iPhones through TestFlight before release.
The simulator has no Taptic Engine either. Haptics that follow the hinge need a fake in unit tests and a real phone to feel.
Will these numbers hold on a real iPhone Duo?
We cannot say yet. Every rate in this post was measured on the simulator. We have no measurement from a physical foldable, and Creaky Hinge’s haptics have not been felt on one. Apple calls the rate system policy, so it could also change with an OS update while the API stays the same.
That is why the principle comes before the numbers. Treat the hinge as sparse samples. Keep your own clock to know when it stopped. Predict the picture, and let the sound react. If a device measurement changes a figure here, this post gets updated with it.
The door
The accordion
Creaky Hinge is where this pipeline ships. It is an iPhone app for iOS 27.1 and later: fold an iPhone Duo and a door, a chest, a lighter, a spellbook or an accordion moves with it, and on any other iPhone you drag instead. It is paid once, with no ads and no account, and there is no Android version. The rest of the shelf is on the Games page.
Frequently asked questions
- How often does onHingeChange update?
- Only when the hinge angle changes, at a rate the system decides. On the iPhone Duo simulator in Xcode 27.1 it delivered roughly 5 to 20 events a second, often 10 to 30 degrees apart. There is no setting that raises the rate.
- Is UIKit's hinge interaction faster than onHingeChange?
- No. On the simulator both delivered the same events, with SwiftUI's arriving about 3 ms after UIKit's. The iOS 27.1 SDK has no Core Motion equivalent for the hinge either.
- How do I know when the hinge has stopped moving?
- Keep your own clock. No event ever reports zero speed, so poll your speed estimate on a timer and treat a quiet spell of about two and a half typical event gaps as a stop. Creaky Hinge clamps that window between 60 and 350 ms.
- Should I interpolate or extrapolate hinge angles?
- Extrapolate. Interpolating has to wait for the next event, which adds a whole event gap of lag. Predict ahead at the measured speed for one expected gap, then ease onto each new event as it arrives.
- What does onHingeChange do on an iPhone without a hinge?
- Nothing. It is never called, because there is no hinge state to change. Do not wait for a nil report; set a short timeout instead. Creaky Hinge waits one second, then lets you drag the door with a finger.
- Is Creaky Hinge on Android?
- No. It is an iPhone app for iOS 27.1 and later, built on the iOS hinge API, and there is no Android version.