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

Image rendering is slow #57

Open
yu-t opened this issue Oct 13, 2020 · 6 comments
Open

Image rendering is slow #57

yu-t opened this issue Oct 13, 2020 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@yu-t
Copy link

yu-t commented Oct 13, 2020

@muukii For large images cgContext.draw(cgImage, in: CGRect(origin: .zero, size: canvasSize)) in public func render(resolution: Resolution = .full) -> UIImage takes too long, about a minute.
Can you please suggest how this can be fixed?

@ntnmrndn
Copy link
Collaborator

Are you using the simulator ? The simulator is very slow, but real device should do it in seconds at most.

@yu-t
Copy link
Author

yu-t commented Oct 14, 2020

@ntnmrndn I use a real device. iPhone XS, 14.0.1.
I try with this photo: https://unsplash.com/photos/ETeQcrvs0No

@Sam-Spencer
Copy link
Contributor

Sam-Spencer commented Mar 24, 2021

@muukii It appears that this function runs on the main thread sometimes, causing the UI to appear blocked. Additionally, the logs show that (for some reason) a CGImage is unavailable from the supplied UIImage. According to Apple's documentation, this can happen when converting between a UIImage and a CIImage... are you addressing this in v2?


It seems that some of the issues also have to do with the TransitionPatch dependency?

@muukii
Copy link
Collaborator

muukii commented Mar 25, 2021

@Sam-Spencer
Thanks.

Firstly, the above function can be run in background-thread.

public func render(resolution: Resolution = .full) -> UIImage

Lager image takes a long time, it's unavoidable.
So would you try to run in backgorund-thread?

In order to render large(full-size) image, we need to use CPU rendering in my opinion.
And some more image manipulations need to use CoreGraphics.
That's why we use CGImage.

@muukii
Copy link
Collaborator

muukii commented Mar 25, 2021

And I thought we could get something optimizations.
If the image only needs cropping, we can get the final image without using CoreGraphics manipulations.

@muukii
Copy link
Collaborator

muukii commented Mar 28, 2021

This PR might faster this.
#76

@muukii muukii added the help wanted Extra attention is needed label Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants