Permanent UI thread hang: unbounded ProcessDelayedPropsNodes retry loop when a native-driver animation targets a view absent from the Fabric registry
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- cpp, react-native
- 领域
- desktop-dev, frontend
调研方向
从 vnext/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp 和 NativeAnimatedNodeManager.cpp 开始,跟踪 StartAnimations()、AddDelayedPropsNode() 和 ProcessDelayedPropsNodes()。使用缺失的 Fabric view 重现问题,并验证重试会让出控制权给 message pump,在满足有界条件后停止,并且不再让 UI thread 永久挂起。
由索引模型根据 Issue 内容生成。
描述
Environment
- react-native-windows 0.84.0 (Fabric / composition, Win32
ReactNativeWin32Apptemplate) - Windows 11 26100, x64, Debug and Release both affected
Summary
If PropsAnimatedNode::StartAnimations() runs while its connected view tag is not present in the Fabric view registry (view unmounted, or its native view detached by react-native-screens on an inactive screen), the animated module enters a tight, unbounded retry loop posted to the UI batching queue. The loop runs inside CoreMessaging's queue drain, so the Win32 message pump is never re-entered: the app goes permanently "Not Responding" with one core pinned at 100%. It never recovers.
Root cause
PropsAnimatedNode::StartAnimations() falls back to AddDelayedPropsNode when the view cannot be resolved (PropsAnimatedNode.cpp):
} else {
if (const auto manager = m_manager.lock()) {
manager->AddDelayedPropsNode(Tag(), m_context);
}
}
AddDelayedPropsNode immediately re-posts ProcessDelayedPropsNodes() to the UI batching queue (NativeAnimatedNodeManager.cpp#L446-L460):
void NativeAnimatedNodeManager::AddDelayedPropsNode(
int64_t propsNodeTag,
const winrt::Microsoft::ReactNative::ReactContext &context) {
m_delayedPropsNodes.push_back(propsNodeTag);
if (m_delayedPropsNodes.size() <= 1) {
winrt::Microsoft::ReactNative::implementation::ReactCoreInjection::PostToUIBatchingQueue(
m_context.Handle(), [this]() { ProcessDelayedPropsNodes(); });
}
}
ProcessDelayedPropsNodes() retries StartAnimations(), which fails again and re-enqueues — with no delay, no retry limit, and no yield back to the message pump. Because the re-post lands in the queue currently being drained by Microsoft::CoreUI::Dispatch::UserAdapter::DrainCoreMessagingQueue, the drain never completes and PeekMessage is never called again.
If the view never reappears (e.g. the React component is still mounted so the JS side never drops the animated node, but the native view stays detached), the loop is infinite.
Call stack (spinning UI thread, symbolized from a full dump with the 0.84.0 NuGet PDBs)
Microsoft_ReactNative!Microsoft::ReactNative::NativeAnimatedNodeManager::ProcessDelayedPropsNodes [Modules\Animated\NativeAnimatedNodeManager.cpp @ 446]
Microsoft_ReactNative!...AddDelayedPropsNode::__l5::<lambda_1>::operator() [Modules\Animated\NativeAnimatedNodeManager.cpp @ 457]
Microsoft_ReactNative!Mso::React::MessageDispatchQueue2::tryFunc [Shared\Threading\MessageDispatchQueue.cpp @ 120]
Microsoft_ReactNative!Mso::QueueService::InvokeTask [Mso\src\dispatchQueue\queueService.cpp @ 208]
Microsoft_ReactNative!Mso::TaskDispatcherHandler<...>::Invoke [Mso\src\dispatchQueue\uiScheduler_winrt.cpp @ 208]
CoreMessagingXP!Microsoft::UI::Dispatching::DispatcherQueue::DeferInvokeCallback
CoreMessagingXP!Microsoft::CoreUI::Dispatch::Dispatcher::Callback_DispatchLoop
CoreMessagingXP!Microsoft::CoreUI::Dispatch::UserAdapter::DrainCoreMessagingQueue
...
CoreMessagingXP!Microsoft::UI::Dispatching::DispatcherQueue::RunEventLoop
Microsoft_ReactNative!winrt::Microsoft::ReactNative::implementation::ReactNativeWin32App::Start
Repeated live samples of the same thread also catch it inside DispatcherQueue::TryEnqueueWorker → TryDeferInvoke (the self-re-post) and in ProcessDelayedPropsNodes's vector teardown — i.e. the whole 100%-CPU loop is enqueue → dispatch → fail → enqueue.
Steps to reproduce
- Fabric composition app with
react-native-screens-style native view detachment (or any timing where a view is removed from the registry while itsPropsAnimatedNodestays connected). - Start an
Animated.timing/springwithuseNativeDriver: truetargeting a transform/opacity on such a view (in our app: a badge pulse animation triggered by a background event while its screen's native views were detached). - UI thread spins forever; window stops responding; only recovery is killing the process.
Observed repeatedly in a production app. Full-memory dumps and additional stacks available on request.
Expected behavior
A native animation whose target view cannot be resolved should be retried with backoff/frame pacing and eventually abandoned (or dropped when the node disconnects) — it must not starve the UI thread's message pump.
Suggested fix
In AddDelayedPropsNode/ProcessDelayedPropsNodes:
- schedule the retry on the next batch/frame instead of immediately re-posting to the queue currently being drained, and
- bound the retries (drop the delayed node and log once the view is gone for good, e.g. after N attempts or when the node is disconnected/dropped).
- 主要语言
- C++
- 星标
- 17.4k
- 派生
- 1.2k
- 平均合并
- 2 天 23 小时
- 30 天内合并 PR
- 16
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/react-native-windows 的其他 Issue
-
Needs: Triage :mag:
难度 2/5 1-3 小时 新手友好度 82/100
microsoft/react-native-windows#16340 ·
维护者通常 2 天内回复
-
bug Needs: Triage :mag:
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/react-native-windows#16321 · 1 条评论 ·
维护者通常 2 天内回复
-
bug Needs: Triage :mag:
难度 3/5 1-2 天 新手友好度 48/100
microsoft/react-native-windows#16479 ·
维护者通常 2 天内回复
-
Needs: Triage :mag:
难度 5/5 一周以上 新手友好度 30/100
microsoft/react-native-windows#16442 · 2 条评论 ·
维护者通常 2 天内回复
-
Fabric: activating the window doesn't announce the window or the focused control to a screen reader未关闭Needs: Triage :mag:
难度 4/5 3-5 天 新手友好度 48/100
microsoft/react-native-windows#16435 ·
维护者通常 2 天内回复
查看 microsoft/react-native-windows 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
scp-fs2open/fs2open.github.com#7914 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
bug low priority rt_lib wasm
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
eclipse-score/inc_someip_gateway#356 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
HarperFast/rocksdb-js#945 ·
维护者通常 1 天内回复