Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe change adds hinge sensor support to the Reanimated API, including angle and status values, availability tracking, and Android and Apple platform handling. Web registration returns an unsupported result for hinge sensors. The common app adds book and horse examples that use hinge data, and the tests cover hinge values, availability behavior, mocks, and types. Priority: ➖ Normal Change: Feature Merge Risk: 🟡 Moderate · up to Hinge sensing may remain unavailable after a temporary startup window failure, and components may show stale sensor availability after registration changes. Resolve these behaviors before merging unless their impact is explicitly accepted. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
c0870b9 to
1acbe5c
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 23ba4350-4f80-4e82-9ddc-7b52fbf20ad0
📒 Files selected for processing (26)
apps/common-app/src/apps/reanimated/examples/AnimatedHingeExample.tsxapps/common-app/src/apps/reanimated/examples/AnimatedHingeHorseExample/HingeCodeExample.tsxapps/common-app/src/apps/reanimated/examples/AnimatedHingeHorseExample/RunningHorse.tsxapps/common-app/src/apps/reanimated/examples/AnimatedHingeHorseExample/colors.tsapps/common-app/src/apps/reanimated/examples/AnimatedHingeHorseExample/highlightCode.tsapps/common-app/src/apps/reanimated/examples/AnimatedHingeHorseExample/horseFrames.tsapps/common-app/src/apps/reanimated/examples/AnimatedHingeHorseExample/index.tsxapps/common-app/src/apps/reanimated/examples/index.tspackages/react-native-reanimated/CHANGELOG.mdpackages/react-native-reanimated/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.cpppackages/react-native-reanimated/Common/cpp/reanimated/AnimatedSensor/AnimatedSensorModule.hpackages/react-native-reanimated/__tests__/sensors.test.tspackages/react-native-reanimated/__tests__/sensorsAvailability.test.tspackages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorListener.ktpackages/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/sensor/ReanimatedSensorType.ktpackages/react-native-reanimated/apple/reanimated/apple/sensor/ReanimatedSensor.hpackages/react-native-reanimated/apple/reanimated/apple/sensor/ReanimatedSensor.mpackages/react-native-reanimated/apple/reanimated/apple/sensor/ReanimatedSensorType.hpackages/react-native-reanimated/src/ReanimatedModule/js-reanimated/JSReanimated.tspackages/react-native-reanimated/src/Sensor.tspackages/react-native-reanimated/src/SensorContainer.tspackages/react-native-reanimated/src/commonTypes.tspackages/react-native-reanimated/src/core.tspackages/react-native-reanimated/src/hook/useAnimatedSensor.tspackages/react-native-reanimated/src/index.tspackages/react-native-reanimated/src/mock.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| if (hinge == nil) { | ||
| [strongSelf reportHingeUnavailable]; | ||
| return; |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Do not convert transient hierarchy loss into permanent sensor unavailability.
Apple reports a nil hinge when the interaction leaves a hierarchy that supplies hinge updates. A missing key window is also a transient UI state. Both paths emit REANIMATED_HINGE_STATUS_UNAVAILABLE, which causes Sensor.markUnavailable() to unregister the sensor and permanently reject later subscriptions for this sensor key. Keep the interaction recoverable when the hierarchy or key window returns, or add reversible availability state. (developer.apple.com)
Also applies to: 214-216
Source: MCP tools
There was a problem hiding this comment.
i believe that is addressed now?
There was a problem hiding this comment.
@pawicao, this addresses the transient hinge == nil case. Later nil updates no longer mark the sensor unavailable.
The missing-key-window case remains. After REANIMATED_HINGE_ATTACH_ATTEMPTS retries, attachHingeInteractionWithAttemptsLeft: calls reportHingeUnavailable. This still permanently marks the sensor unavailable if the key window becomes available after the retry limit.
You are interacting with an AI system.
There was a problem hiding this comment.
check it again, close this thread if it is completed
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
git rev-parse --short HEAD
ast-grep outline packages/react-native-reanimated/apple/reanimated/apple/sensor/ReanimatedSensor.m --match 'attachHingeInteractionWithAttemptsLeft|initializeHinge|reportHingeUnavailable'
ast-grep outline packages/react-native-reanimated/src/Sensor.ts --match 'markUnavailable|register'
ast-grep outline packages/react-native-reanimated/src/hook/useAnimatedSensor.ts --match 'useAnimatedSensor'
rg -n -C 6 'REANIMATED_HINGE_ATTACH_ATTEMPTS|attachHingeInteractionWithAttemptsLeft|reportHingeUnavailable|handleHingeUpdate|markSensorUnavailable|markUnavailable\(' packages/react-native-reanimated/apple/reanimated/apple/sensor/ReanimatedSensor.m packages/react-native-reanimated/src/Sensor.ts packages/react-native-reanimated/src/SensorContainer.ts packages/react-native-reanimated/src/hook/useAnimatedSensor.tsLength of output: 16159
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,112p' packages/react-native-reanimated/src/Sensor.ts
sed -n '145,213p' packages/react-native-reanimated/src/hook/useAnimatedSensor.ts
sed -n '32,95p' packages/react-native-reanimated/src/SensorContainer.tsLength of output: 6362
@pawicao, the additional check confirms the finding.
Sensor.markUnavailable() sets sensorId to -1. SensorContainer.registerSensor() then rejects future registrations because sensor.isAvailable() returns false. Therefore, when the key window appears after the retry limit, the hinge sensor cannot recover.
The thread must remain open.
You are interacting with an AI system.
1acbe5c to
9f4df20
Compare
9f4df20 to
adce1f0
Compare
adce1f0 to
ff1951c
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 599501b8-be5a-406d-b840-c488f5f130d2
📒 Files selected for processing (4)
packages/react-native-reanimated/__tests__/sensors.test.tspackages/react-native-reanimated/__tests__/sensorsAvailability.test.tspackages/react-native-reanimated/apple/reanimated/apple/sensor/ReanimatedSensor.mpackages/react-native-reanimated/src/hook/useAnimatedSensor.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
464070c to
ca444a6
Compare
2f04caf to
63c6c5a
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
63c6c5a to
840d745
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
e750495 to
03e837a
Compare
03e837a to
504c6e4
Compare
44493f5 to
9f44ff2
Compare
9f44ff2 to
d5760ec
Compare
SensorType.HINGE reports the hinge angle in radians and a HingeStatus, and takes no config. Android reads Sensor.TYPE_HINGE_ANGLE and derives the status from the angle. iOS reads UIHingeInteraction, which reveals a hinge only through its updates, so ReanimatedHingeProbe attaches one to a hidden window when the app's first scene connects. The answer arrives a few milliseconds later, before JS renders, so isAvailable is correct on the first render like for every other sensor. A nil hinge update is dropped. Web has no hinge sensor.
d5760ec to
06aef74
Compare
Note
This PR description is AI-generated.
Requires #10662.
Summary
Foldable devices expose a hinge angle, but
useAnimatedSensorhad no sensor type for it. I addedSensorType.HINGE, which reports the angle in radians and aHingeStatusfromSensor.TYPE_HINGE_ANGLEon Android andUIHingeInteractionon iOS 27.1, takes no config, and has no web counterpart. iOS reveals a hinge only through the updates of the interaction, soReanimatedHingeProbeattaches one to a hidden window when the app's first scene connects, and the answer arrives a few milliseconds later, before JS renders.isAvailableis therefore correct on the first render on both platforms, the hook keeps reading it withuseMemo, and the probe moves to another scene when its scene disconnects so the hinge data keeps flowing. I also made iOS cancel its sensors when the module is invalidated and added two example screens.Test plan
Jest sensor tests and the tstyche tests for
useAnimatedSensorpass. On the iOS 27.1 iPhone Duo simulator and on an Android emulator with a virtual hinge,isAvailableistrueon the first render and the angle and status follow the hinge, also after a JS reload on iOS.Changelog
yarn changelog:addfor each changed package, or this PR does not changereact-native-reanimatedorreact-native-worklets.