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

Fix intermittent CALayerInvalidGeometry crash after memory warning #45

Merged
merged 1 commit into from
Nov 12, 2015

Conversation

johnboiles
Copy link
Contributor

Fixes #44

I could reproduce this crash by mashing cmd-shift-m to trigger memory warnings around the time JDFlipNumberView is laying out. This crash was caused by _topImages getting cleared out upon memory warning. Here's the sequence of events:

  1. Memory warning -- _topImages is cleared
  2. JDFlipNumberView layoutSubviews is called
  3. JDFlipNumberDigitView's sizeThatFits: method calls [self imageSize] which calls [factory imageSizeForBundleNamed:self.imageBundleName]
  4. imageSizeForBundleNamed: doesn't recreate _topImages so the size is returned as CGSizeZero
  5. JDFlipNumberDigitView's sizeThatFits: runs the line CGFloat origRatioW = imageSize.width/(imageSize.height*2);, resulting in a NaN (divide by 0)
  6. The NaN is set as the height for the JDFlipNumberDigitView's frame
  7. CALayerInvalidGeometry crash

This fixes the issue by using topImagesForBundleNamed: instead of accessing topImages directly. topImagesForBundleNamed: recreates the topImages if they're not available.

calimarkus added a commit that referenced this pull request Nov 12, 2015
Fix intermittent CALayerInvalidGeometry crash after memory warning
@calimarkus calimarkus merged commit a4eadb7 into calimarkus:master Nov 12, 2015
@calimarkus
Copy link
Owner

awesome thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CALayerInvalidGeometry crash in JDFlipNumberDigitView.m
2 participants