Search code examples
iosiphoneios9xcode10

EXC_BAD_ACCESS KERN_INVALID_ADDRESS ios < 9.3 xcode 10


with latest xcode I'm having a crash only on ios 9.0>9.2.x

#0. Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x227dbae6 objc_msgSend + 5
1  CoreUI                         0x2700b023 -[CUICatalog _resolvedRenditionKeyFromThemeRef:withBaseKey:scaleFactor:deviceIdiom:deviceSubtype:sizeClassHorizontal:sizeClassVertical:memoryClass:graphicsClass:graphicsFallBackOrder:] + 646
2  CoreUI                         0x2700ad99 -[CUICatalog _resolvedRenditionKeyForName:scaleFactor:deviceIdiom:deviceSubtype:sizeClassHorizontal:sizeClassVertical:memoryClass:graphicsClass:graphicsFallBackOrder:withBaseKeySelector:] + 284
3  CoreUI                         0x2700a52b -[CUICatalog namedLookupWithName:scaleFactor:deviceIdiom:deviceSubtype:sizeClassHorizontal:sizeClassVertical:] + 94
4  UIKit                          0x279aba2d __98-[_UIAssetManager imageNamed:scale:idiom:subtype:cachingOptions:sizeClassPair:attachCatalogImage:]_block_invoke + 496
5  UIKit                          0x279ab77f -[_UIAssetManager imageNamed:scale:idiom:subtype:cachingOptions:sizeClassPair:attachCatalogImage:] + 230
6  UIKit                          0x279abf51 -[_UIAssetManager imageNamed:withTrait:] + 408
7  UIKit                          0x2747694d +[UIImage imageNamed:inBundle:compatibleWithTraitCollection:] + 172    
8  UIKit                          0x272d6537 +[UIImage imageNamed:] + 110
9  SuperGuidaTV                   0x140ffd -[FixedBackgroundNavigationController viewDidLoad] (FixedBackgroundNavigationController.m:375)
10 SuperGuidaTV                   0x126dfd -[ISNavigationController viewDidLoad] (ISNavigationController.m:522)
11 UIKit                          0x274fd075 -[UIViewController _sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 60
12 UIKit                          0x27199d79 -[UIViewController loadViewIfRequired] + 1028
13 UIKit                          0x27199959 -[UIViewController view] + 24

The crash happens in this code: (Inside viewDidLoad)

[super setDelegate:self];
[super viewDidLoad];
[self backgroundImageView];

if (!_backgroundImage)
    [self setBackgroundImage:[UIImage imageNamed:@"BkImage"]];

the [self backgroundImageView] just initialize a UIImageView with the frame as the self.view and the setBackgroundImage just set an image taken from the XCAsset folder.

-(UIImageView *)backgroundImageView {
    if (!_backgroundImageView)
    {
        _backgroundImageView = [[UIImageView alloc] initWithImage:self.backgroundImage];
        [self.view insertSubview:_backgroundImageView atIndex:0];
        [_backgroundImageView setFrame:self.view.bounds];
        [_backgroundImageView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
    }
    return _backgroundImageView;
}

-(void)setBackgroundImage:(UIImage *)backgroundImage {
    _backgroundImage = backgroundImage;
    if (self.forceNoBackground)
    {
        [self.backgroundImageView setHidden:YES];
        return;
    }
    else if (_backgroundImageView) [self.backgroundImageView setImage:backgroundImage];
}

As you can see from the log the crash happens right after the uiimage is set.

I have other crashes only on ios 9 always for a Bad Access.

The target is set to deployment target to 9.0, but the project was set to 8.3 Project deployment target

could this be the cause? Should i move the image out of the XCasset folder?

Thank you very much.


Solution

  • Thank you to all you guys responding to my problem: as said in the comments the issue is the same of: our app crashed in iOS 9 which upload by Xcode 10

    and is resolved in xcode 10.1 beta2

    Resolves an issue that affected app compatibility with iOS 9.0, 9.1 and 9.2. Apps containing asset catalogs built with Xcode 10 whose deployment target was set to iOS 9.0, 9.1 or 9.2 would produce content incompatible with the runtimes of those iOS versions. Rebuilding the application with Xcode 10.1 resolves this issue. (44535967)

    This issue gave my app too many crashes...

    Thank you very much