CNA-BUG-241: docs/devices-event-contract.md and docs/devices-thread-safety.md describe sensor behaviour the code no longer has
Evidence basis: source-verified at the pinned commit; tests exist (not executed for this page). Claims on this page were checked by reading the CNA source at commit 009d40f5; unless a sentence says otherwise, nothing here was built or executed. Nothing on this page was executed unless the Evidence section says so.
The event contract says the Android bridge swallows handler exceptions silently, and the thread-safety document misnames the counter guard for two sensors and calls same-instance Start/Dispose safe while its known-gap section says otherwise.
- Identifier
CNA-BUG-241- Category
- Bug
- Subsystem
- Documentation & release tooling
- Status
- Open
- Verified against
- CNA
009d40f5(009d40f5dd085c4e674d3479675fac84b12b3e0a) - Severity
- Low (a triage suggestion, not a project priority)
- Evidence basis
- Source-verified: read at TARGET, not executed
- Tests touching this area
- Yes: see Current tests
- Affected contract
- docs/devices-event-contract.md section 6 (exception semantics) and docs/devices-thread-safety.md (per-class guarantees and the known gap)
Expected behaviour
CNA's devices maintainer documents describe what the code does; the internals pages, the devices workflow and future fixes cite them.
Actual behaviour at TARGET
docs/devices-event-contract.mdsection 6, headed "decided but not yet uniformly implemented", says thecallback_(sample)site inAndroidSensorBridge::Runis wrapped in a barecatch (...) { }"with no logging and no test-visible counter at all" and leaves the fix to DEVPERF-005. At TARGET,AndroidSensorBridge.cppcatchesstd::exceptionand everything else and records aNativeDiagnosticRecordthroughNativeDiagnosticSink::Record, citing DEVPERF-005, and nineNativeDiagnosticSinkTestcases pin the sink.docs/devices-thread-safety.mdsays instance construction and destruction never corrupt the shared counter, "guarded by astatic instanceCountMutex_". OnlyCompassandMotionhave that mutex;AccelerometerandGyroscopeguard their counter withPlatformSensorSubsystem<TSensor>::mutex_. The guarantee holds; the named mechanism is wrong for two classes.- The same document says
Accelerometer/GyroscopeStart()/Stop()/Dispose()"are safe to call concurrently with each other, on the same or different instances", while its "Known gap" section says aDispose()racingStart()on the same instance is unsupported for all four classes, with the read-unlock-Stop()shape present inAccelerometer.cppandGyroscope.cpp.
Source locations
docs/devices-event-contract.md— section 6 describes the Android bridge as silentdocs/devices-thread-safety.md— instanceCountMutex_ attribution; same-instance safety claim versus the Known gap sectionmodules/devices/src/Sensors/Detail/AndroidSensorBridge.cpp— AndroidSensorBridge::Run routes handler exceptions to NativeDiagnosticSink::Recordmodules/devices/tests/Microsoft/Devices/Sensors/Detail/NativeDiagnosticTests.cpp— NativeDiagnosticSinkTest casesmodules/devices/src/Sensors/Accelerometer.cpp— constructor and Dispose(bool) guard instanceCount_ with the subsystem mutex; Dispose reads started_ and then calls Stopmodules/devices/src/Sensors/Compass.cpp— the static instanceCountMutex_ exists only in Compass and Motion
Evidence
Checked by reading the two documents and the sensor sources and tests named above at 009d40f5; not executed. In each contradiction the code is the correct side, and nothing marks the documents as describing a future state. The devices internals page already flags the first two points.
Focused reproduction
# Shown for reference: the stale statements next to the code.
grep -n "bare" docs/devices-event-contract.md
grep -n "NativeDiagnosticSink::Record" modules/devices/src/Sensors/Detail/AndroidSensorBridge.cpp
grep -rn "instanceCountMutex_" modules/devices/src/Sensors/
grep -n "same or different instances" docs/devices-thread-safety.md
Current tests
NativeDiagnosticTests.cpp pins the sink; nothing checks the documents against the code.
Regression test
Rewrite section 6 to state the uniform NativeDiagnosticSink policy and its debug-only log line; name PlatformSensorSubsystem::mutex_ for Accelerometer/Gyroscope; restrict the first bullet to what the known-gap section allows.
Blast radius
Maintainers and reviewers who trust the documents: someone following section 6 may re-implement diagnostics that exist or treat the Android path as silent, and the thread-safety bullet invites concurrent Dispose/Start on one instance. No runtime behaviour changes.
Workaround
Trust the code and the devices internals page over these two documents.
Related pages
The same subject is explained at several altitudes. These are the neighbouring pages at each one.
- Maintainer workflow
- Thread and callback map: sensors
- Deep dives
- Sensors and vibration: delivery
- Known issues
- Bug index