You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

修改ASTextNode的AttributedText导致父ASTableNode闪烁问题咨询

Fixing ASTableNode Flicker When Updating ASTextNode's AttributedText in Texture

Hey there! This is a super common issue folks run into when working with Texture (formerly AsyncDisplayKit), so let’s break down what’s going on and how to fix it.

First: Yes, this is almost certainly a thread issue

Texture’s node properties (like attributedString on ASTextNode) must be modified on the main thread. Notification callbacks can sometimes fire on background threads depending on how the notification is posted—if you’re updating the text node off the main thread, it causes inconsistent rendering, which leads to that annoying flicker you’re seeing.

The Quick Fix

Wrap your text update code in a main thread dispatch to ensure it’s executed correctly:

DispatchQueue.main.async {
    self.likes.countLabel.attributedString = NSMutableAttributedString(string: "\(newCount)", attributes: self.likes.font)
}

In most cases, this alone will eliminate the flicker. Texture handles layout invalidation automatically when you modify node properties on the main thread, so you shouldn’t need to manually call setNeedsLayout() or setNeedsDisplay()—but if you’re dealing with a custom node setup, adding those calls inside the main thread block might help in edge cases.

Have Others Seen This?

Absolutely! This comes up frequently in the Texture community. The root cause is almost always off-main-thread modifications to UI-related node properties. Texture’s async rendering pipeline relies on consistent state from the main thread, so any changes made elsewhere throw off the rendering cycle.

Bonus Checks

If the flicker still happens after fixing the thread issue, double-check:

  • That countLabel is properly added as a child node to its parent (no accidental duplicate nodes or layout conflicts)
  • That you’re not accidentally reinitializing the text node instead of updating its attributed string
  • That your parent node’s layout spec is stable (no unexpected layout recalculations triggered by the text update)

内容的提问来源于stack exchange,提问作者sushibrain

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:37:42