Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashes with iOS 16 and Swift 5.6 #11

Open
Karthikeyan1108 opened this issue Sep 27, 2022 · 4 comments
Open

Crashes with iOS 16 and Swift 5.6 #11

Karthikeyan1108 opened this issue Sep 27, 2022 · 4 comments

Comments

@Karthikeyan1108
Copy link

let delaySeconds = UIImage.delayForImageAtIndex(Int(i),
source: source)
delays.append(Int(delaySeconds * 1000.0)) // Seconds to ms

@kundanjadhav
Copy link

Anyone got any solution for this?

@FrhaanSaqib
Copy link

crash occurring on the line of
let delaySeconds = UIImage.delayForImageAtIndex(Int(i),
source: source)
delays.append(Int(delaySeconds * 1000.0)) // Seconds to ms

@tomatobin
Copy link

fixed by add defer:

let cfProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil)
let gifPropertiesPointer = UnsafeMutablePointer<UnsafeRawPointer?>.allocate(capacity: 0)
defer {
gifPropertiesPointer.deallocate()
}

@ashishkakkad8
Copy link

ashishkakkad8 commented Jun 5, 2023

Change code after the following line:

let cfProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil)

Create gifPropertiesPointer and deallocate it will fix the issue in iOS 16.x

let gifPropertiesPointer = UnsafeMutablePointer<UnsafeRawPointer?>.allocate(capacity: 0)
defer {
    gifPropertiesPointer.deallocate()
}
let unsafePointer = Unmanaged.passUnretained(kCGImagePropertyGIFDictionary).toOpaque()
if CFDictionaryGetValueIfPresent(cfProperties, unsafePointer, gifPropertiesPointer) == false {
    return delay
}

let gifProperties: CFDictionary = unsafeBitCast(gifPropertiesPointer.pointee, to: CFDictionary.self)

I have tried and it's working fine for me.

Hope it will help you. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants