[uni-app x][iOS] 手指点击 showModal 按钮关闭后,弹窗页销毁时闪退(CSSAnimationController::teardownAll / CancelIOSKeyframeAnimationForRemoval)

Open
#6,096 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
43/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
ios, javascript
Domain
mobile-dev

Research direction

Start by reviewing the supplied crash stacks and reproduction steps, then trace the iOS Page::Destroy cleanup path through CSSAnimationController::teardownAll and CancelIOSKeyframeAnimationForRemoval. The issue reports a repeatable crash when a finger tap closes a modal while its button animation may still be running; done means reproducing and fixing that crash so repeated modal confirmations and toast displays do not crash or hang on iOS.

Written by the indexing model from the issue text.

Description

问题描述

uni-app x 蒸汽模式,iOS 真机上手指点击 uni.showModal 的按钮关闭弹窗后(紧接着再 uni.showToast 会更快),重复几十次 App 闪退,偶尔是卡死后被系统看门狗强杀。业务里 showActionSheet 点选项、showModal 点确认后提示,正常使用就会频繁闪退。

崩溃都在弹窗页销毁时清理 CSS 动画:Page::Destroy → CSSAnimationController::teardownAll → CancelIOSKeyframeAnimationForRemoval(EXC_BAD_ACCESS)。

复现步骤

新建 uni-app x 工程(manifest 开启 "vapor": true、"vapor-render-target": "bytecode"),页面如下,运行到 iOS 真机(标准基座):

<template>
  <view style="padding: 16px">
    <button @click="manual">showModal 点确定后 showToast(快速重复)</button>
    <text>已执行 {{ count }} 次</text>
  </view>
</template>

<script setup lang="ts">
const count = ref(0)
function manual() {
  uni.showModal({
    title: '提示',
    content: '点确定后会弹 toast,再快速点按钮',
    success: (res) => {
      if (!res.confirm) return
      count.value++
      uni.showToast({ title: '已执行 ' + count.value, icon: 'none', duration: 2000 })
    },
  })
}
</script>
  1. 点按钮弹出确认框
  2. 用手指点「确定」(弹出 toast)
  3. 立即再点按钮、再点「确定」……快速重复

我们用 WebDriverAgent 自动点击(点确定 → 0.4s → 点按钮 → 0.5s 循环),第 84 轮(191 秒)闪退。

对照实验:

方式 结果
代码连续 showToast,每 200ms 一次 910 次不崩
代码 showModal → 300ms 后 hideModal → showToast 循环 295 次不崩
代码 showActionSheet → 300ms 后 hideActionSheet 循环 398 次不崩
手指点击确认框「确定」关闭 → showToast 第 84 轮闪退;另一次卡死后被看门狗强杀
业务工程:手指点确认框按钮 → showToast 第 3 轮(12 秒)闪退
业务工程:同上,去掉 showToast 第 24 轮(134 秒)闪退

只有手指点击按钮关闭时会崩,代码开关不崩。

预期结果

弹窗正常关闭,App 不闪退、不卡死。

实际结果

  1. 闪退(大多数,SIGSEGV):
EXC_BAD_ACCESS (SIGSEGV) KERN_INVALID_ADDRESS (possible pointer authentication failure)
DCloudUniappRuntime  uniappx::ios::CancelIOSKeyframeAnimationForRemoval(uniappx::UniAnimation*, bool)
DCloudUniappRuntime  vue::css::CSSAnimationController::teardownAllWithResolver(std::function<uniappx::Element* (int)> const&)
DCloudUniappRuntime  vue::css::CSSAnimationController::teardownAll(uniappx::Page&)
DCloudUniappRuntime  uniappx::Page::Destroy()::$_0::operator()()
DCloudUniappRuntime  uniappx::thread::ThreadTaskRunner::runAsyncTask(...)
Foundation           __NSThreadPerformPerform
...
DCloudUniappRuntime  -[NSThreadRunner threadMain:]

真机上一周收集到 21 份崩溃日志,16 份是这个栈。

  1. 卡死后被看门狗强杀(SIGKILL 0x8BADF00D,scene-update watchdog transgression),主线程卡在:
libobjc   weak_unregister_no_lock / objc_destroyWeak
Gestures  ...
UIKitCore -[UIGestureRecognizer dealloc]
  1. 偶发:页面销毁时回收 list-view 列表项

crash-logs.zip

crash-logs.zip

DCloudUniExtComponent  recycle_list::RecycleListItem::removeInstance(std::string const&)
DCloudUniExtComponent  recycle_list::RecycleListItem::~RecycleListItem()
DCloudUniappRuntime    vue::VueElement::unmountComponent(...)

系统信息:

  • 发行平台: uni-app x App(iOS),蒸汽模式,视图层编译目标:机器码
  • 操作系统: iOS 27.0.1(24A446)
  • HBuilderX版本: HBuilderV Alpha,uni-app x SDK 5.33(5.33.2026102115-alpha),标准基座 5.33.101018
  • 设备信息: iPhone 14(iPhone14,7)

Android 上同样操作不崩。

补充信息

推测:手指按下弹窗按钮时,按钮的按下效果(CSS 动画)还在进行,弹窗页就被关闭销毁,teardownAll 取消这个动画时访问了已释放的对象。

附件:崩溃日志(.ips)。

Dominant language
JavaScript
Stars
41.7k
Forks
3.7k
Avg merge
1d 7h
Merged PRs (30d)
5

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dcloudio/uni-app

All issues in dcloudio/uni-app

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.