alexiscreuzot / SwiftyGif

High performance GIF engine
MIT License
2.02k stars 212 forks source link

Crash: fatal error: Can't form Range with upperBound < lowerBound #29

Closed IsaiahJTurner closed 7 years ago

IsaiahJTurner commented 7 years ago

The breakpoint hits in UIImage+SwiftyGif.swift and the app crashes with the message Crash: fatal error: Can't form Range with upperBound < lowerBound

I am trying to play a gif with 100 loops and memory limit 20. I've also included the gif file that caused the issue. It seems to be reproducable. image

//caclulate the time when each frame should be displayed at(start at 0)
for i in 1..<delays.count{ delays[i] += delays[i-1] }
nishanth-saka commented 7 years ago

Same Problem; please help! Thank you..

IsaiahJTurner commented 7 years ago

This seems to happen when the Gif is invalid. Such as trying to create a Gif from this text:

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>messages-data/11387/image.gif</Key><RequestId>C3DDF27CDDDDD4DD</RequestId><HostId>SDFjh/jfasd89UHFSDNlas89fdhsduIOUAEHF/sdfhiwerjD/FhjH+JJsdfJLKfdsfnkJHEkjdsfNKJw=</HostId></Error>
EdenShapiro commented 7 years ago

I get the same issue when using a protobuf compiler. Any answers to this?

alexiscreuzot commented 7 years ago

Couldn't reproduce this issue on current version

agustindc-rga commented 7 years ago

I am running into the same issue if the data that is passed to init(gifData:Data) is not a valid gif.

let s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>messages-data/11387/image.gif</Key><RequestId>C3DDF27CDDDDD4DD</RequestId><HostId>SDFjh/jfasd89UHFSDNlas89fdhsduIOUAEHF/sdfhiwerjD/FhjH+JJsdfJLKfdsfnkJHEkjdsfNKJw=</HostId></Error>"

if let data = s.data(using: .utf8)  {
    let gifImage = UIImage(gifData: data)