iOS 7 UIImagePickerView shows black preview initially - ios

I am trying to call in a UIImagePickerView and sometimes when my camera view (with custom overlay) shows up it gives black preview initially. And after 15-30 seconds the black screens disappears. If the image is clicked with black camera screen, it still shows up in my UIImageView.
I followed up with the following similar posts:
iOS 7 UIImagePickerController has black preview
and
iOS 7 UIImagePicker preview black screen
I tried doing both. I have managed all the UI jobs on specific background thread and the getter method fix in the second link. But it was not fixed completely either way.
Here is another similar question explaining the problem I am facing, iDevice camera shows black instead of preview
I am still confused why is this bug actually occurring? how can it be reproduced? (as it appears sometimes only) and What's the right fix for this?

I ran into this same problem with the camera preview tonight, and the root cause of the problem was … completely unrelated code in the app delegate that modified UI on a background queue.
Once I eliminated the calls to UI code from background queues, the camera preview became fast and reliable.
This article ( cocoanetics.com/2013/02/uiview-background-queue-debugging ) was very helpful in tracking down where the UI was being modified from a background queue.

Related

UIWebView HTML 5 game Canvas drawing slowness in iOS 9, or WebGL crashing in iOS 8.0 and above

I've having an issue with UIWebView and running HTML 5 games (that another developer is working on). We've tried two different options, and neither is optimal.
Option 1: He renders the HTML 5 game with "canvas drawing". When he does it this way, nothing crashes, however in iOS 9 when we go back into the app from the background, the Web View loads back up, but the game is moving much slower than normal (issue not on iOS 7.1 and above). By much slower I'm talking about the animations are not moving the same velocity that they were when we first load the game. The weird thing about this issue is that even if the user opens up a different HTML 5 game (we're adding multiple games) the animations are slower for that game as well. I've tried dismissing the Web View Controller when the UIApplicationWillResignActiveNotification gets posted. When I set the game up this way, the slowness only happens if the app is in the for 4 seconds (it's very strange).
Option 2: He renders the game with "WebGL". When he renders it this way, the app crashes when the app gets backgrounded on iOS 8.0 and above. My research into the crash is that iOS can't draw OpenGL ES in the background. I'm assuming that the WebGL commands are running similar commands as OpenGL ES would do, hence the crash. Dismissing the Web View Controller on UIApplicationWillResignActiveNotification still causes the crash to happen.
Has anyone else ever dealt with a situation like this?
I've not found a good solution to the problem, but I did find a work around.
When I get the App Will Resign Active message, I remove the UIWebView from the UIWebViewController's subview. When I get the Did Become Active message, I add the UIWebView to the UIWebViewController's subview.
This solution works for both cases.

Animation in Launch Screen in xcode 6

I want to animate a set of images in my Launch Screen, but I do not know how. I have seen some tutorials telling me to put code in the App Delegate (DidFinishLaunchingWithOptions) and nothing has worked.
Could someone help me animate my Launch Screen?
I am supposing that you do quite a bit of work on launch, and you do not want your user to stare at a static image while this work is going on. What you need to do is do the work in the background (using gcd). This way, the launch screen will be gone quickly. However, you are not ready of course: hence your need for animations. So what I do is add my own equivalent of the start screen on top of my first visible UIView, do my animations and then tear down my start up screen. If you want to see what I do in action, try it out with my App (The Opera Player)

Five Finger Pinch to Close (Pinch to Home) Black Screen

What is my app supposed to do (or might it currently be doing incorrectly) to support correct visuals when a five finger pinch to close gesture is executed by the user?
When the five finger pinch to close app gesture is performed on my iPad app, the image of my app UI that is used for the shrinking transition is a black screen. There is one exception; when my app is first launched the gesture uses the correct snapshot of my app UI as long as I do not navigate away from the initial screen.
As a test, I added the code below to see if I could get a red screen in all cases. The result was a red screen in the case that used to show my app UI, and still get a black screen in the failure case.
- (void)applicationWillResignActive:(UIApplication *)application
{
UIView *aView = UIApplication.sharedApplication.keyWindow.subviews.lastObject;
UIImageView *imageView = [[UIImageView alloc] initWithFrame:aView.bounds];
imageView.backgroundColor = [UIColor redColor];
[aView addSubview:imageView];
}
I realize this question is vague, but what I am hoping for is insight into where iOS is getting the screen it uses during the pinch to close gesture. Based on the above code there is more to it than applicationWillResignActive.
I am building with Xcode 5.1.1, iOS 7.0 deployment target, problem occurs running on iOS7 and iOS8 (all versions up to and including public release of 8.1).
Edit
If I continue the shrink gesture by pinching further and further, when the thumbnail image of my app gets to about 25% of the screen size, the empty black image snaps to a correct image of my app UI. At that point I can reverse the gesture (spread my fingers apart) and the correct image grows all the way to full screen. During this process, the image is crisp and not scaled.
If I have focus in a text field and tap and hold with one finger to bring up the magnification loupe, then drop my other four fingers and start the shrink, the black screen shows my UI in a circle where the loupe was (rest is black).
As I mentioned in the comments below, a double tap on the home button always yields a correct snapshot for fast app switching.
My app does not have any background threads running and is not requesting specific permissions to run long running tasks in the background.
Any change your app uses -drawViewHierarchyInRect:afterScreenUpdates:YES anywhere? I'm seeing the same issue when using that API. It seems like there are quite a few GPU bugs related to setting afterScreenUpdates to YES.
Changing my app to use renderInContext (cpu instead of gpu) fixed the problem, but doing that introduces other issues, so it's a toss up.

camera view - can settings disrupt button response on a camera view on iPhone 5S?

I have a strange situation...
I implemented an in-app camera based on Apple's AVCam sample. It works just fine. My question is not about the actual camera implementation, but rather... What could cause a view's buttons to work on one iPhone 5S but fail on another iPhone 5S. Both are using the same build of the app, they have the same iOS version installed (7.0.4), etc.
The problem is...the camera starts and the camera preview displays just fine, but the buttons on that view (i.e. the shutter release, flash options, front/back camera switch, etc) all fail to respond. His iPhone 5S is the only one out of 4 iPhone 5S's that has the problem.
Trying to narrow down what can be different until I can hook the "sad" iPhone 5S up to my debugger in a few days when I see my client again (it's his)... we did notice that my phone asked for permission to access my photos and his did not...
Is there perhaps some system setting that he could have enabled that would cause this check to be skipped? I ask because I wonder if the camera scene's view controller is waiting for something from that check and therefor hanging the UI.
Any ideas would be appreciated
Finally tracked down the issue...
The difference was that on my developer phone, I had a few hundred to 1000 pictures in my camera roll. On my client's phone, he had about 6,000 pictures, so obviously getting those takes longer. If we were patient, the view eventually did come back alive after the enumeration block finished.
Also, I was asking my UICollectionView to scroll to the end (where the newest photos are) after it had finished loading all the camera roll images into itself. With few photos, the timing was fine, but with lots of photos, the timing was off and it was trying to scroll before it had finished enumerating. The solution, since there is no callback for "didFinishReloadingData" was no call the scroll method using -performSelector:withObject:withDelay to ensure that it gets called AFTER the enumeration block and reloadData are finished.

iphone app - white screen shows when launching, or when app suspends

we're having a bit of a headache with some apps, Perhaps anyone of you may be able to alleviate the pain, here goes:
We have an OpenGLES(1) application, and it works fine on any device yet tested, from ipod touch on 3.2 to iphone 4, ipad 1, with iOS 4.2.
however, when the user clicks 'home' twice while the app is running, the application view moves up to accommodate the phone's 'taskbar', but then the view turns white.
I suspect after reading various posts this is because I have not yet implemented the 'applicationWillResignActive' delegate method, but I'm unsure if this is indeed the case, and if so, how I would go about avoiding the white screen. Incidentally, there is also the problem that the background EAGLView goes white (or away ?) when an UIAlertView is added to the mainWindow.view, which seems to me a related problem.
I would much appreciate any suggestions.
Jonathan
Your framebuffer is being destroyed, probably in EAGLView or somewhere similar.
Rebuild the framebuffer after you get control back.

Resources