Macaw-Examples icon indicating copy to clipboard operation
Macaw-Examples copied to clipboard

Crash for iOS 13

Open topDev15 opened this issue 5 years ago • 1 comments

class NodeRenderer {

weak var view: MView?

fileprivate let onNodeChange: () -> Void
fileprivate let disposables = GroupDisposable()
fileprivate var active = false
weak var animationCache: AnimationCache?

init(node: Node, view: MView?, animationCache: AnimationCache?) {
    self.view = view
    self.animationCache = animationCache

    onNodeChange = { [unowned node, weak view] in
        guard let isAnimating = animationCache?.isAnimating(node) else {
            return
        }

        if isAnimating {
            return
        }

            DispatchQueue.main.async {
            print("setNeedsDisplay=6")
                view?.setNeedsDisplay()
            }
    }

    addObservers()
}

view?.setNeedsDisplay() needs to be wrapped with DispatchQueue.main.async {}. If not, we have crash for iOS 13. But after we wrap it, it is very slow when changing color of shape. I found the reason. When changing color of shape, this framework is doing rerendering for whole group using group rendering. Now it needs to be called for main thread as you can see above. But the speed is very slow because of calling main thread much time. How can we fix this issue? Please let me know if you have any thought.

topDev15 avatar Dec 05 '19 15:12 topDev15

Did you get a fix?

museum-future avatar Jun 23 '20 10:06 museum-future