kaandedeoglu / KDCircularProgress

A circular progress view with gradients written in Swift
MIT License
1.21k stars 217 forks source link

crash on iOS 9.3.6 #119

Open pop-goes-the-Weasel opened 4 years ago

pop-goes-the-Weasel commented 4 years ago

while using this framework on devices containing iOS latest 9.3.6 version , there is a crash on the following

override init() {
super.init()
}

of private class KDCircularProgressViewLayer: CALayer

Xcode: 11.5 MacOS: Catalina Device: iPad 3

pop-goes-the-Weasel commented 4 years ago

@kaandedeoglu you're help would be appreciated

StevenBolin commented 4 years ago

I am having the same problem.

kaandedeoglu commented 4 years ago

Do you have any crash logs, screenshots, or any leads you can post here please?

StevenBolin commented 4 years ago

Sure.

Screen Shot 2020-07-02 at 9 39 02 AM
pop-goes-the-Weasel commented 4 years ago

i have my live app crashing to this, please provide a fix for it or point me in the right direction to the resolution of this crash. screenshot and .log file is attached for further debugging process. Just remember, to reproduce this you'll need ipad with lower ios version i.e 9.3.6 version and a latest xcode i.e 11.5

Screen Shot 2020-07-27 at 12 36 54 PM

kCircularCrash.log

@kaandedeoglu

kaandedeoglu commented 4 years ago

@HamzaAtcoding I unfortunately don't own such device to reproduce the crash. One possible solution comes to mind:

It seems like the crash occurs while KDCircularProgress is being initialized through the IB. (KDCircularProgress is created through init(coder:) but KDCircularProgressViewLayer is created through init())

One thing you can try is to only keep a container UIView for KDCircularProgress in the IB. And in viewDidLoad create the progress view programatically and add to the container, would that solve the issue?

pop-goes-the-Weasel commented 4 years ago

as per your recommendation i have made the KDCircularProgress in viewdidload for UIView container programmatically,

//        progressView = KDCircularProgress(frame: CGRect(x: 0, y: 0, width: 300, height: 300))
        progressView = KDCircularProgress(frame: CGRect(x: 0, y: 0, width: 300, height: 300), colors: UIColor.cyan)
//        progressView.startAngle = -90
//        progressView.progressThickness = 0.2
//        progressView.trackThickness = 0.6
//        progressView.clockwise = true
//        progressView.gradientRotateSpeed = 2
//        progressView.roundedCorners = false
//        progressView.glowMode = .forward
//        progressView.glowAmount = 0.9
//        progressView.set(colors: UIColor.cyan ,UIColor.white, UIColor.magenta, UIColor.white, UIColor.orange)
//        progressView.center = CGPoint(x: view.center.x, y: view.center.y + 25)
        view.addSubview(progressView)

these are my findings,

whatever init() i use required public init(coder aDecoder: NSCoder) going through storyboard

convenience public init(frame:CGRect, colors: UIColor...) going through convenience init

override public init(frame: CGRect) going through public

all of these leads to crash in the designated overridden init(), i have trimmed it down as much as to close all properties and create a simple frame and add in view, but still a crash.

Maybe it has to do something in the way frame is created in KDCircularProgress that might be iOS 10+ versions dependent and not found in lower iOS version?

@kaandedeoglu

kaandedeoglu commented 4 years ago

@HamzaAtcoding I'm really sorry, but I don't have anything. I'm not clear how a simple init is crashing..

pop-goes-the-Weasel commented 4 years ago

any debugging that would help? @kaandedeoglu

pop-goes-the-Weasel commented 4 years ago

could this be the issue with older iPads not having enough memory? i got this through debugging session with address sanitizer

==436==AddressSanitizer CHECK failed: /BuildRoot/Library/Caches/com.apple.xbs/Sources/clang_compiler_rt/clang-1103.0.32.62/compiler-rt/lib/sanitizer_common/sanitizer_mac_libcdep.cc:24 "((res != ((void *)-1))) != (0)" (0x0, 0x0)
    <empty stack>
kaandedeoglu commented 4 years ago

I don't think so, this library was initially developed during iOS 9 was the latest, and it used to work fine. I unfortunately don't have devices / Xcode versions to reproduce it on.

If I were you, I would start dissecting and see what causes the crash. For example just try to keep KDCircularProgress & KDCircularProgressLayer, removing more and more properties as you go along. I have a suspicion the @NSManaged trick might be causing issues..

pop-goes-the-Weasel commented 4 years ago

After a solid dev day on trying to fix this, i can say for sure that this is 110% issue related to older iPads having less memory (i can confirm this by running this on xcode >11.5, compiling and not crashing on it), in the binaries updation of xcode 11.5 it most definitely updated something that causes older iPads memory to take a hit, after-all apple is known for deprecating their older products in devious ways. Even though this was developed in iOS 9.x times as mention by @kaandedeoglu, nobody can foresee the impending wreck that could have been caused by xcode updation, also as i mentioned earlier i have trimmed down the properties i.e. (angles, startAngle, clockwise, progressThickness etc) to just an extent to just make a frame out of it, but still crash took place