ChartsOrg / Charts

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.
Apache License 2.0
27.6k stars 6k forks source link

Crash during animation on dismissed VC #4989

Open julien-tamade opened 1 year ago

julien-tamade commented 1 year ago

What did you do?

I am running a series of two delayed animations when a view controller appears. override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(100)) { [ weak self] in self?.graphView?.moveViewToAnimated(xValue: 20000, yValue: 0, axis: .left, duration: 0.5, easingOption: .easeOutQuad) DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(750)) { self?.graphView?.moveViewToAnimated(xValue: 0, yValue: 0, axis: .left, duration: 0.5, easingOption: .easeInOutQuad) } } } If the view controller is dismissed mid animation, the app crashes

What did you expect to happen?

I would expect the app not to crash

What happened instead?

The app crashed `open class AnimatedMoveViewJob: AnimatedViewPortJob { internal override func animationUpdate() { var pt = CGPoint( x: xOrigin + (CGFloat(xValue) - xOrigin) phase, y: yOrigin + (CGFloat(yValue) - yOrigin) phase )

    transformer.pointValueToPixel(&pt)
    viewPortHandler.centerViewPort(pt: pt, chart: view)
}

} it crashed on the linetransformer.pointValueToPixel(&pt)`

Charts Environment

Charts version/Branch/Commit Number: 4.1.0 Xcode version:14.0.1 Swift version:5 Platform(s) running Charts:iOS macOS version running Xcode:12.6

Demo Project

fengli12321 commented 1 year ago

Same problem,did you solve it? May you can back to v3.6.0

fengli12321 commented 1 year ago

Same problem,did you solve it? May you can back to v3.6.0 When VC pop or dismiss, 'transformer' and 'viewPortHandler' will be released, so it crashed. In old version (v3.6.0), this property is modifiered by 'weak', so It run good

ChanRoy commented 1 year ago

Same problem

Toj-dev commented 5 months ago

Same problem