Comments (3)
Does it happen with the demo app?
More generally, you may be doing some picture processing in the main thread, try using Grand Dispatch Central to do it in other threads with lower priority.
from ios-nbuimagepicker.
I was not able to get down to the bottom of what seems like a deadlock. I am doing some image processing on the main thread. Here is my code:
[NBUImagePickerController startPickerWithTarget:self options:options customStoryboard:nil resultBlock:^(NSArray *imagesOrMediaInfos) {
id mediaObject = [imagesOrMediaInfos firstObject];
if ([mediaObject isKindOfClass:[UIImage class]]) {
UIImage *image = (UIImage *)mediaObject;
UIImage *transformedImage = [image transformToSquareImage];
[self.btnSelectPhoto setImage:nil forState:UIControlStateNormal];
self.imageView.image = transformedImage;
self.pngData = UIImageJPEGRepresentation(transformedImage, 0.9);
}
}];
And here is the method in my UIImage category:
- (UIImage *)transformToSquareImage {
float currentImageWidth = self.size.width;
float currentImageHeight = self.size.height;
float diff = currentImageWidth - currentImageHeight;
if (diff == 0) {
return self;
}
CGSize desiredSize = CGSizeMake(MAX(currentImageWidth, currentImageHeight), MAX(currentImageWidth, currentImageHeight));
UIGraphicsBeginImageContext(desiredSize);
UIImage *image1;
UIImage *image2;
if (diff > 0) {
// Width is greater than the height
image1 = [OCCommon createImageWithColor:[UIColor blackColor] size:CGSizeMake(currentImageWidth, diff / 2)];
image2 = [OCCommon createImageWithColor:[UIColor blackColor] size:CGSizeMake(currentImageWidth, diff / 2)];
[image1 drawInRect:CGRectMake(0 ,0, image1.size.width, image1.size.height)];
[self drawInRect:CGRectMake(0, image1.size.height, currentImageWidth, currentImageHeight)];
[image2 drawInRect:CGRectMake(0, image1.size.height + currentImageHeight, image2.size.width, image2.size.height)];
} else if (diff < 0) {
// Height is greater than the width
image1 = [OCCommon createImageWithColor:[UIColor blackColor] size:CGSizeMake(-diff / 2, currentImageHeight)];
image2 = [OCCommon createImageWithColor:[UIColor blackColor] size:CGSizeMake(-diff / 2, currentImageHeight)];
[image1 drawInRect:CGRectMake(0 ,0, image1.size.width, image1.size.height)];
[self drawInRect:CGRectMake(image1.size.width, 0, currentImageWidth, currentImageHeight)];
[image2 drawInRect:CGRectMake(image1.size.width + currentImageWidth, 0, image2.size.width, image2.size.height)];
}
UIImage *finalImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return finalImage;
}
With this code, I would assume that the main thread would only temporarily be blocked until the processing is finished. Am I missing something?
from ios-nbuimagepicker.
Yes, it should "just" temporarily freeze your app, which isn't good, but shouldn't stop the app altogether.
Try debugging in Xcode by hitting pause when your app gets frozen. Then check the stack trace to see what it was doing.
As for the picker, once it calls your resultBlock
it is dismissed and shouldn't be doing anything else. In other words, I'm pretty sure it's on your side.
from ios-nbuimagepicker.
Related Issues (16)
- Getting Couldn't load Nib named: NBUImagePickerController HOT 3
- EXC_BAD_ACCESS in NBUAssetsGroup libraryChanged HOT 1
- 'Pods-environment.h' file not found HOT 1
- memory not release HOT 4
- Grey gradient background overlay app view after dismissing picker HOT 5
- NBUCoreImageFilterProvider [ciImage autoAdjustmentFilters]; No longer exists in iOS 9 HOT 9
- How can I get Apple default filters and Can I add new Apple filter if not found. HOT 3
- Zoom Feature HOT 3
- Images count issue HOT 5
- It seems no way to preset flash mode for imagepicker. HOT 7
- Come up with a clean way to configure not-yet loaded views' properties from controllers or Picker.
- Performing segue causes error of taking photo HOT 5
- Customize NBUAssetsLibraryViewController in a non-storyboard project HOT 2
- NBUAssetsGroupViewController.gridView infinite loop in layoutSubviews HOT 6
- Initialize NBUCameraView in viewDidAppear or viewDidLayoutSubviews HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ios-nbuimagepicker.