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

NoCopyRendering experiment: Fix possible memory leak if image node rendering is canceled #trivial #765

Merged
merged 2 commits into from
Jan 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Source/ASImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,9 @@ + (UIImage *)createContentsForkey:(ASImageNodeContentsKey *)key drawParameters:(
key.didDisplayNodeContentWithRenderingContext(context, drawParameters);
}

// The following `UIGraphicsGetImageFromCurrentImageContext` call will commonly take more than 20ms on an
// A5 processor. Check for cancellation before we call it.
// Check cancellation one last time before forming image.
if (isCancelled()) {
UIGraphicsEndImageContext();
ASGraphicsEndImageContext();
return nil;
}

Expand Down
3 changes: 3 additions & 0 deletions Source/Details/ASGraphicsContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
*
* The API mirrors the UIGraphics API, with the exception that forming an image
* ends the context as well.
*
* Note: You must not mix-and-match between ASGraphics* and UIGraphics* functions
* within the same drawing operation.
*/

NS_ASSUME_NONNULL_BEGIN
Expand Down