Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7669599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:37:48+00:00 2026-05-31T15:37:48+00:00

Somewhere along the line, my app started crashing on the iPad though it still

  • 0

Somewhere along the line, my app started crashing on the iPad though it still works great in the Simulator. I’m using XCode 4.3.1, and deploying on iOS 5.1.

The relevant code is below. It crashes when executing ImageLayer’s drawInContext: method.

ImageLayer.h:

#import <QuartzCore/QuartzCore.h>

@interface ImageLayer : CALayer {}

@property (nonatomic, retain) NSString *path;

@end

ImageLayer.m:

#import "ImageLayer.h"

@implementation ImageLayer

@synthesize path;

- (void)drawInContext:(CGContextRef)ctx
{
    [super drawInContext:ctx];
    CGImageRef img = [UIImage imageWithContentsOfFile:path].CGImage;
    NSLog(@"path = %@", path);
    if (img) {
        CGRect rect = CGContextGetClipBoundingBox(ctx);
        CGContextTranslateCTM(ctx, 0.0, rect.size.height);
        CGContextScaleCTM(ctx, 1.0, -1.0);
        rect = CGContextGetClipBoundingBox(ctx);
        CGContextDrawImage(ctx, rect, img);             // Crashes here!
        CGContextScaleCTM(ctx, 1.0, -1.0);
    }
}

@end

LayeredView.h:

#import <UIKit/UIKit.h>

@interface LayeredView : UIView {}

@end

LayeredView.m:

#import "LayeredView.h"
#import "ImageLayer.h"

@implementation LayeredView

- (id)initWithFrame:(CGRect)frame 
{
    self = [super initWithFrame:frame];
    if (self) {
        NSString *path = [[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent: @"Letter A"] stringByAppendingPathComponent:@"bg.png"];
        ImageLayer *l = [ImageLayer layer];
        l.path = path;
        l.frame = CGRectMake(0, -27, 1024, 795);
        [self.layer addSublayer:l];
        [l setNeedsDisplay];
    }
    return self;
}

Crash Log

Incident Identifier: F0104517-289E-4B50-BBD0-5E9E0B19BAE8
CrashReporter Key:   dc4048f7e9778dfac3941d3352d4edac4a35bd47
Hardware Model:      iPad2,1
Process:         ABC [4843]
Path:            /var/mobile/Applications/88FE4107-4433-4A36-A511-0B9619B256EB/ABC.app/ABC
Identifier:      ABC
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2012-03-16 14:38:30.326 -0700
OS Version:      iPhone OS 5.1 (9B176)
Report Version:  104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x371a132c 0x37190000 + 70444
1   libsystem_c.dylib               0x33307208 0x332ba000 + 315912
2   libsystem_c.dylib               0x33300298 0x332ba000 + 287384
3   GraphicsServices                0x333d987c 0x333d5000 + 18556
4   GraphicsServices                0x333da2bc 0x333d5000 + 21180
5   UIKit                           0x35b50c5a 0x35b1f000 + 203866
6   ABC                             0x000e045c 0xdf000 + 5212
7   ABC                             0x000e0400 0xdf000 + 5120
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:37:49+00:00Added an answer on May 31, 2026 at 3:37 pm

    Found it. By changing this line

    CGImageRef img = [UIImage imageWithContentsOfFile:path].CGImage;
    

    to

    UIImage *image = [UIImage imageWithContentsOfFile:path];
    CGImageRef img = image.CGImage;
    

    everything works fine. My guess is that ARC hangs on to just the CGImageRef, and disposes of the image, unless a variable is allocated for it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Somewhere along the line I picked up the notion that using iframes is 'bad
Somewhere along the line from the DB to the application, this: sauté is getting
I've probably murdered the whole concept of MVC somewhere along the line, but my
Somewhere I did something silly. I was deploying my Rails app via cloning the
Something really weird is happening: when I call foo(100*1.0f), somewhere along the line that
my code broke somewhere along the way, and crashes when using the navigation bar
Somewhere along the line I decided that having classes for position would be a
I have an MVC application which uses a silverlight control. Somewhere along the line
Somewhere along the line, some huge, huge file got added to the git repository
(big) (big) Somewhere along the way into the function animationWithFrames , my vector loses

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.