Skip to content

fix(ios): prevent PagerView crash on duplicate states in queue#10247

Closed
huhuanming wants to merge 2 commits intoxfrom
fix/ios-pager-view-duplicate-states-crash
Closed

fix(ios): prevent PagerView crash on duplicate states in queue#10247
huhuanming wants to merge 2 commits intoxfrom
fix/ios-pager-view-duplicate-states-crash

Conversation

@huhuanming
Copy link
Copy Markdown
Contributor

@huhuanming huhuanming commented Feb 13, 2026

Summary

  • 修复 iOS 上 PagerView 快速切换 tab 时因 Duplicate states in queue 导致的致命崩溃
  • setPagerViewControllers 方法中增加 transitioning 状态守卫,防止在上一次动画过渡未完成时重复调用 setViewControllers
  • 清理 patch 文件中误包含的 android/build/ 构建产物

Root Cause

UIPageViewController 内部的 _UIQueuingScrollView 不支持并发的入队过渡。当用户快速切换 tab 或程序化页面同步与用户操作重叠时,两次 setViewControllers:direction:animated:completion: 调用会导致队列中出现重复状态,触发 NSInternalInconsistencyException 断言崩溃。

现有 patch 已有 recycling、nil、边界检查等守卫,但缺少对 transitioning 状态的检查。

Fix

if (transitioning && animated) {
    NSLog(@"[PagerView] setPagerViewControllers blocked: already transitioning");
    [self enableSwipe];
    return;
}

Test plan

  • iOS 上快速连续点击 Earn 区域的 Assets/Portfolio/FAQs tab,确认不崩溃
  • 从其他页面导航回 TabDiscovery 后立即点击 tab,确认不崩溃
  • 正常 tab 切换功能不受影响
  • Android 行为无变化

Sentry Event: 6f5ce7dc764d49189bed67414df232e4

🤖 Generated with Claude Code


Open with Devin

Add transitioning guard in setPagerViewControllers to prevent calling
setViewControllers while a previous animated transition is in progress.
UIPageViewController's internal _UIQueuingScrollView does not support
concurrent enqueued transitions and crashes with
"Duplicate states in queue" (NSInternalInconsistencyException).

Also removes accidentally included android/build/ artifacts from the patch.

Analyzed from Sentry crash report: 6f5ce7dc764d49189bed67414df232e4
@revan-zhang
Copy link
Copy Markdown
Contributor

revan-zhang commented Feb 13, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 6 additional findings.

Open in Devin Review

@originalix originalix marked this pull request as draft February 13, 2026 11:10
@huhuanming huhuanming closed this Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants