We had been utilizing SVGs in our iOS venture for our belongings, but it surely appears to be like prefer it was making our app rather more heavy and now we additionally discovered that’s making our app slower (inflicting flickering when scrolling).
After some testing, we did a comparability between utilizing PNGs, SVGs, PDFs, HEICs:
- 201ms – SVG WITH PRESERVED DATA (and 1534ms in excessive circumstances!!)
- 4ms – SVG NO PRESERVED DATA
- 215ms – PDF WITH PRESERVED DATA
- 4ms – PDF NO PRESERVED DATA
- 5ms – PNG very huge decision
- 96ms – HEIC (which is bizarre… in different belongings is 5ms)
Take a look at code:
let body = CGRect(x: 0, y: 0, width: 500, top: 500)
let begin = CFAbsoluteTimeGetCurrent()
(0..<10).forEach { _ in
UIImage(named: imageName)!.draw(in: body)
}
let diff = CFAbsoluteTimeGetCurrent() - begin
print("TIME: (Int(diff * 1000))ms - (imageName)")
We lastly modified to solely use PNG, which is appears to be 40x quicker. We used ImageOptim to optimize dimension, and on the finish our Assests.automobile shrank from 5mb to 1mb.
So, after our exams… is there any level to make use of vectorial photos in iOS? Perhaps solely when you actually need to make a picture very huge with out caring about efficiency?
Are my exams okay or I’m lacking one thing? Thanks!