diff --git a/README.md b/README.md index 1425ec7..90876e5 100644 --- a/README.md +++ b/README.md @@ -94,11 +94,11 @@ The library reports geometry and does not reposition content. Normal safe area i ## Measurement timing -The first measurement requests synchronous delivery; later changes are regular +On Android, the first measurement requests synchronous delivery; later changes are regular events. Android measures after Fabric mounting and again on its own relayout, fold changes and window inset changes; scrolling -or moving an ancestor does not trigger a measurement. On iOS, same-frame delivery requires React Native -[#58530](https://github.com/react/react-native/pull/58530); see +or moving an ancestor does not trigger a measurement. On iOS, every measurement is a regular +event; see [measurement timing](https://rnrr.appandflow.com/docs/platforms#measurement-timing). Readiness indicates a completed measurement, not a universal first-frame guarantee. diff --git a/ios/ReservedRegionsView.mm b/ios/ReservedRegionsView.mm index 04b3897..0364d0d 100644 --- a/ios/ReservedRegionsView.mm +++ b/ios/ReservedRegionsView.mm @@ -116,12 +116,12 @@ - (void)updateRegions return; } _hasDispatchedRegions = YES; - eventEmitter->experimental_flushSync([eventEmitter, regions = std::move(regionPayloads)]() mutable { - eventEmitter->dispatchEvent( - "regionsChange", - folly::dynamic::object("regions", std::move(regions)), - RawEvent::Category::Discrete); - }); + // Not experimental_flushSync: it makes the main thread wait for JS, so a JS call that uses + // dispatch_sync to the main queue at that moment deadlocks the app (#45). + eventEmitter->dispatchEvent( + "regionsChange", + folly::dynamic::object("regions", std::move(regionPayloads)), + RawEvent::Category::Discrete); } - (void)prepareForRecycle diff --git a/website/docs/platforms.md b/website/docs/platforms.md index e398f8f..8a0bab1 100644 --- a/website/docs/platforms.md +++ b/website/docs/platforms.md @@ -66,8 +66,8 @@ On Android: - A parent view that consumes window insets can prevent cutout updates from reaching the provider. - After a provider is detached and reattached, it only measures again if its position or size within its parent, folding features, or cutout changed while detached. -The first measurement requests synchronous delivery to React. Later measurements use regular events. React Native limits synchronous delivery to one event per view and event name per frame, so regular events allow later changes in the same frame to be delivered. Intermediate updates may be combined before JavaScript processes them. +On Android, the first measurement requests synchronous delivery to React. Later measurements use regular events. React Native limits synchronous delivery to one event per view and event name per frame, so regular events allow later changes in the same frame to be delivered. Intermediate updates may be combined before JavaScript processes them. -On iOS, processing the first measurement in the same frame requires [React Native #58530](https://github.com/react/react-native/pull/58530). The example’s React Native `0.88.0-rc.1` does not include it. +On iOS, every measurement uses a regular event. A synchronous flush makes the main thread wait for JavaScript, and a JavaScript call that waits for the main thread at the same moment would deadlock the app. Readiness confirms that a measurement has completed. It does not guarantee that the resulting layout appears in the first visible frame.