Skip to content

Commit

Permalink
NoCopyRendering experiment: Fix possible memory leak if image node re…
Browse files Browse the repository at this point in the history
…ndering is canceled #trivial (#765)

* Fix memory leak if image node rendering is canceled

* Update comment
  • Loading branch information
Adlai-Holler authored and Adlai Holler committed Jan 23, 2018
1 parent 2e98588 commit 6b94b94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

0 comments on commit 6b94b94

Please sign in to comment.