BSXPCMessage received error for message: Connectio

2019-01-16 09:40发布

问题:

UPDATE: Reference #19285042 and submit bug reports to apple

Very weird error and not finding anything online. Its saying "BSXPCMessage received error for message: Connection interrupted"

I'm just doing some basic filter applications. The error message ONLY occurs if I reassign the UIImageView.image to another UIImage. If I comment out just that line I will not get the error. So if you can think of any reason why this message appears when I assign a filtered image to a UIImageView that would be incredibly helpful.

If you can suggest any cause for this error I would appreciate it.

#import "FilterTestsViewController.h"

@interface FilterTestsViewController ()

@end

@implementation FilterTestsViewController

UIImage* _originalImage;
UIImage* _filterImage;
UIImageView* _uiImageView;

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self initialize];
    //flip image by 180*

}

-(void)initialize
{
    _originalImage = [UIImage imageNamed:@"ja.jpg"]; //creates image from file, this will result in a nil CIImage but a valid CGImage;
    [self createFilterImage];
    _uiImageView = [[UIImageView alloc] initWithImage:_filterImage]; //creates a UIImageView with the UIImage
    [self.view addSubview:_uiImageView]; //adds the UIImageView to view;
}

-(void)createFilterImage
{
    NSString* filterName = @"CIFalseColor";
    CIImage* ciImage = [CIImage imageWithCGImage:_originalImage.CGImage];
    CIFilter* filter = [CIFilter filterWithName:filterName keysAndValues:kCIInputImageKey,ciImage, nil];
    _filterImage = [UIImage imageWithCIImage:[filter outputImage]];
}

@end

回答1:

The message you are getting is due to a CIFilter bug in iOS 8.

XPC Services are meant to reduce crashes by isolating less stable components such as filters and plugins. This is usually not fatal and the connection will be restored by launchd restarting the service. Since this is not a long running service, but simply an operation, chances are that your image filter is not actually being applied.

This is very much a bug in iOS 8, and you should file a Radar (bug report) to let Apple know that (yet another piece of) iOS 8 has a bug.

If you are going to do that, you should install Quick Radar, keep track of the Radar number, and reply to the many other similar questions on Stack Overflow with the same issue. Encourage other people to file a duplicate Radar report referencing your original issue. That will give the bug more attention at Apple.

Apple really rushed this one out. The previously mentioned workaround is fine if you can make a different CIFilter subclass do what you want. Otherwise, you will just have to tinker around with copying the image, saving its NSData representation, or otherwise removing it from the CIImage workflow in some other way.



回答2:

From reading a raywenderlich article, I found that adding an option to the context, so that rendering is done in the CPU rather than the GPU, will remove the warning.

let context = CIContext(options:[kCIContextUseSoftwareRenderer : true])



回答3:

For me the issue was occurring when I would try to use CIFilters in iOS8+ for some reason?

I added some code to check iOS version and if it was greater than 7.9.9 I would use a CIFilter substitute that's iOS8+ like: https://stackoverflow.com/a/24083728/2057171

On a separate side-note, xCode6 had removed CIFilter framework from my project altogether (strange), but adding it back didn't fix this crash...



回答4:

This worked for me:

OBJ-C

CIContext *context = [CIContext contextWithOptions:@{kCIContextUseSoftwareRenderer:@(YES)}];

Swift

let context = CIContext(options:[kCIContextUseSoftwareRenderer : true])

Ref: https://stackoverflow.com/a/29872829/3411787