简体   繁体   中英

Why is simulator very slow when using CIFilter

I am using CIFilter to create image filter and show it on a image view. What happen is that it works fine on a iphone device but works very slow on simulator. Below is the code. I wander why simulator is so slow compare to the device. Is there a way to increase simulator memory or cpu in order to make it work as similar as a device?

func outputImage(filter: CIFilter, originalImage: UIImage) -> UIImage{
    print(filter)
    let inputImage = CIImage(image: originalImage)
    filter.setValue(inputImage, forKey: kCIInputImageKey)
    let outputImage =  filter.outputImage
    let cgImage = context!.createCGImage(outputImage!, fromRect: (outputImage?.extent)!)
    return UIImage(CGImage: cgImage, scale: 1, orientation: originalImage.imageOrientation)
}

Check Debug -> Toggle Slow Animations is Unchecked 你可能不小心选中了,这也是性能的一个原因。

I wander why simulator is so slow compare to the device

It's because the simulator doesn't use the GPU. The Xcode 11 / Catalina combination is the first to use the GPU in the simulator.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM