Aviary ios SDK memory not released after dismiss - ios

I am using Aviary SDK 3.0 in my app, I put the Aviary code in a popover like this, but after I dismissed the popover using [popover dismissPopoverAnimated], the Aviary is still in the memory Heap, this is even true, even after I dismissed the parent viewcontroller. is it expected that the Aviary code is cleaned up after I dismiss?
in the action when use tap the photo. I present it here
AFPhotoEditorController *editorController = [[AFPhotoEditorController alloc] initWithImage:imageToEdit];
[editorController setDelegate:self];
if (popover == nil)
popover = [[UIPopoverController alloc] initWithContentViewController:editorController];
else
[popover setContentViewController:editorController animated:YES];
https://dl.dropboxusercontent.com/u/23238574/Screenshots/aviarypopover.png

From the docs:
"Note that pushing the controller onto a UINavigationController's stack is not recommended, since the Photo Editor itself uses a subclass of UINavigationController."
try presenting it modally, then what I do just to make me feel better about all memory getting cleaned is to make a strong property and go through the checklist
[editorController removeFromParentViewController];
editorController.delegate = nil;
editorController = nil;
something about clearing the delegate seems to clear my memory better, although, I don't think you need it.
also, don't forget:
"By default, Aviary keeps a small number of OpenGL objects loaded to optimize launches of Aviary products."
[AFOpenGLManager requestOpenGLDataPurge];
// to request a clear,
// "Calls to requestOpenGLDataPurge only apply to the currently loaded OpenGL data,"
You can set it to clear regularly with
[AFPhotoEditorCustomization purgeGPUMemoryWhenPossible:YES];
if you're doing this, it's a good idea to preload some of the editor if you know they'll be using it soon
[AFOpenGLManager beginOpenGLLoad];

This memory leak has been addressed in subsequent releases of the SDK. Please visit developers.aviary.com to get the latest version.

Related

iOS App Maximise Disappears

I have developed an iOS app and everything is working as expected apart from the "maximise" icon in the detail view when it is turned sideways has disappeared.
I can't seem to find any documentation on this feature and suspect I have either not initialized something in the code or missed a setting on the story board.
Using objective C.
Knowing what it was called helps a lot :-)
Issue was the below code missing from viewDidLoad in the DetailViewController
UINavigationController *navigationController = [self.splitViewController.viewControllers lastObject];
navigationController.topViewController.navigationItem.leftBarButtonItem = self.splitViewController.displayModeButtonItem;

Why does [uiActionSheet showInView:self.view.window] "hang" in iOS8?

I have an app in AppStore (iPhone-only, iOS3.1+ compatible, 2011 Xcode 3 compile) that has been working amazingly fine for three years untouched. Recently however it started "freezing" on iOS8 under certain conditions. That happens in couple of places, both when UIActionSheet is to be shown. Nothing pops on screen, the app does not crash but instead stays irresponsive to any taps; nothing in system console. The only way "out" after that happens is to kill the app manually from the task switcher and start it again.
I believe the reason is the way i show the UIActionSheet, which was as simple as these 3 lines, from a UIViewController method:
UIActionSheet* actSheet = [[UIActionSheet alloc] initWithTitle:#"Could not connect to [...]" delegate:nil cancelButtonTitle:#"OK" destructiveButtonTitle:nil otherButtonTitles:nil];
[actSheet showInView:self.view.window];
[actSheet autorelease];
I think the reason is the use of self.view.window, which is UIWindow (which inherits UIView, naturally) - and that just using self.view should solve the issue (i read here https://stackoverflow.com/a/26171717/226086 that showInView: now only works with UIView with UIViewController attached). Why did i use self.view.window in the first place - probably i read about this issue with cancel button alignment.
However, i am unable to reproduce the problem when compiling my app in Xcode 6 - and Xcode 3 cannot debug iOS8. And my conundrum is how do i exorcise a bug i cannot reproduce to verify.
Do you have insight on the changed behavior of UIActionSheet, what is causing the hanging in iOS8?
PS. Please don't tell me "UIActionSheet is deprecated in iOS8, use UIAlertController instead". That is an incorrect answer: "deprecated" does not mean UIActionSheet does not work in iOS8 no more - it is just discouraged for new code and may be dropped in next versions. But i want to keep compatibility with iOS5+ (my reasoning akin to this) so i rather fix the use of it - which i mention above seems fishy with showInView:self.view.window.
This is a long shot, but there is an issue in iOS8 related to rotation not working when the following line is left in your app delegate didFinishLaunchingWithOptions: method. The line is a hangover from pre iOS8 xcode generation and relates to the window for the application. Only affects iOS8. Previous versions all work fine.
The line is:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
This is nolonger needed and should be commented out. Given you are using self.view.window perhaps there is some side effect with UIActionSheet as well.
As I say, a long shot but seems a coincidence that your having an issue in iOS8 only related to using a window view.
I dont think you should have an issue using UIAlertController, as far as support for previouis versions of iOS are concerned you can try creating instance of UIAlertController using [[UIAlertController alloc] init] if it returns nil(which it will for older versions of iOS) you can use UIAlertSheet you are using currently.

willRotateToInterfaceOrientation not called on iOS8

I'm using the VFR PDF viewer library in my app, where I present it thus:
ReaderDocument *document = [ReaderDocument withDocumentFilePath:pdfFile password:nil];
ReaderViewController *vc = [[ReaderViewController alloc] initWithReaderDocument:document];
[self.navigationController pushViewController:vc animated:YES];
If I run on iOS7, everything works fine.
If I run my app on iOS8, the willRotateToInterfaceOrientation method in ReaderViewController never gets called, so when the device is rotated the document doesn't get reformatted correctly.
However, if I run the demo app that comes with the library on iOS8, the willRotateToInterfaceOrientation in ReaderViewController does get called, which leads me to believe the library is ok, and I'm doing something wrong (or neglecting to do something) in my app.
I'm rather puzzled at this behaviour. Why doesn't willRotateToInterfaceOrientation get called in my app on iOS8, but it does under the other variations? How can I try to track this down?
I finally managed to resolve my problem; here is what the issue was in case anyone else has the same problem.
My ReaderViewController was being presented from a class that had implemented viewWillTransitionToSize:withTransitionCoordinator:, so the deprecated methods on child view controllers weren't being called.
Also in that implementation it wasn't calling
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]
and so the viewWillTransitionToSize:withTransitionCoordinator: method of all child view controllers wasn't being called either.
The fix was to add a call to
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]
into the parent VC's viewWillTransitionToSize:withTransitionCoordinator: method, subclass ReaderViewController, then add a viewWillTransitionToSize:withTransitionCoordinator: to my subclass to call the appropriate methods in ReaderViewController.
Simply because willRotateToInterfaceOrientation is no more called in iOS8, it is deprecated.
If the new rotation methods are not implemented, and a project is
compiled with the iOS 8 SDK, the view controllers -will not receive
calls- to the deprecated rotation methods.
A similar question to yours can be found here
Citation of #mluisbrown :
The rotation methods are deprecated in the iOS 8 SDK. This will have
no effect at all on apps built with the iOS 7 SDK, even running in iOS
8 and probably several future versions of iOS.
I struggled a bit with some kind of a similar problem to yours. I tried following Apple recommendation to use viewWillTransitionToSize, which in my case did not solve my problem because this only gets triggered on changes from regular to compact for example an not on rotation.
viewWillTransitionToSize:withTransitionCoordinator: to make
interface-based adjustments.
Which is detailed in apple documentation
Also a video of WWDC 2014 explains this but I can't remember which video it was. Perhaps the one on What's new in Cocoa touch or the one on View Controller Advancements in iOS 8.
EDIT
Note that in my case viewWillTransitionToSize, as explained, was not called because I wasn't changing from regular to compact so there was no size transition, strictly speaking for Apple.
The only solution I fount was to handle this manually in the viewDidLayoutSubviews of the corresponding view controller.
In my case I wanted to keep track of the top cell displayed in a tableview with autolayout. As it wasn't tracked automatically by the system, I had to check that manually and scroll manually to the adequate cell on rotation. That's why I did it that way. It's quite "heavy" but works in my case.
I would also be interested if anyone has an easier solution.

How can I schedule a new presentation in transitionCoordinator after popover dismissal

I am updating my app to support iOS 8. In a few places, I do a modal presentation after popover dismissal. This is the code I used for iOS 7
[self.POP dismissPopoverAnimated:YES];
// initialization code for self.SMVC
MPTAdvancedSearchNav* nav = [[MPTAdvancedSearchNav alloc]initWithRootViewController:self.SMVC];
nav.modalPresentationStyle = UIModalPresentationFormSheet;
[self.navigationController presentViewController:nav animated:YES completion:nil];
When I run this on an iOS 8 device, I see a lag (about 1/4 of a second) before UIModalPresentationFormSheet animation begins.
I did some research and found this WWDC video https://developer.apple.com/videos/wwdc/2014/#214 (minute 29) that says I should use a transition coordinator to schedule a new presentation after the popover dismissal.
Problem is, I cant figure out how to do this. I think I am supposed to use
- (void)notifyWhenInteractionEndsUsingBlock:(void (^)(id<UIViewControllerTransitionCoordinatorContext> context))handler
Is this the method I should use? Also, how do I get a hold of UIViewControllerTransitionCoordinatorContext
Unfortunately, Popovers were only converted to a "presentation style" in iOS 8, so you'll still need the old code you have for iOS 7, and have a fork in there for iOS 8 specific code. On top of that, in order to make everything work nicely, you'll have to abandon UIPopoverController because it does not inherit from UIPresentationController, which is a requirement to hook into the transitioning system in iOS 8 for popovers specifically. All UIPopoverController does in iOS 8 is wrap UIPopoverPresentationController.
However, I think there's an easier solution that will work nicely in both 7 & 8: have whatever class is doing the creation / presentation of MPTAdvancedSearchNav become the delegate of UIPopoverController, and implement didDismissPopover:, and move your code into there that will do the presentation.
Checkout the docs here, and let me know how that works - https://developer.apple.com/Library/ios/documentation/UIKit/Reference/UIPopoverControllerDelegate_protocol/index.html#//apple_ref/doc/uid/TP40009307

UIImagePickerController Showing Black Preview Screen

I am having a problem when calling the UIImagePickerController to use the camera. Sometimes, but more often than none, the preview screen shows to be black (as the camera itself is covered). After doing some research, it seems that people where not delegating it correctly..however, I believe my set up is correct. A restart of the app is what fixes it.
In my .h file I have included UIImagePickerControllerDelegate and UINavigationControllerDelegate.
Here is the code for the .m file
- (IBAction)camera:(id)sender {
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
#if TARGET_IPHONE_SIMULATOR
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
#else
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
#endif
imagePickerController.editing = YES;
imagePickerController.delegate = self;
[self presentViewController:imagePickerController animated:YES completion:nil];
}
Any ideas as to why this is happening?
Thank you
I just fought this issue for a day and a half, sure enough I was doing something UI related outside the main thread. In my case I was updating a label in the response handling code for an asynchronous web service call.
In an app with several view controllers that have 2000+ lines of code each in them, this kind of thing can be very difficult to track down. This is what finally brought me to my answer, and VERY quickly at that.
https://gist.github.com/steipete/5664345
This guy posted a class you can download and add to your project. Simply add it to your project, you don't need to use it anywhere or try to instantiate anywhere, just add it to your project. He also states that you should run this without ARC. To do that, go to your Build Phases tab, expand Compile Sources, double click on the file and then type -fno-objc-arc
Now, run your project and navigate to where you are experiencing the black image preview screen. If all goes to plan, at some point prior to that your app should crash and dump to console some information about performing a UIKit action outside the main thread. Based on what your app was doing and what was dumped to console, you should be able to very quickly find the line of code causing you troubles. In my case I was able to call my response handler with a
[self performSelectorOnMainThread:#selector(handleResponse:) withObject:data waitUntilDone:true];
and my problem was gone immediately
Also, this issue only began once I updated to iOS 7, I never saw this in iOS 5 or iOS 6.
The guy who posted the file advises that you do not ship your app with this file included in your project and I strongly agree with that.
Happy debugging!
Try this. it solved my problem, make sure that there is a value
(Application name as string) in your info.plist > "Bundle display name".
In my case it was empty and because of that it didn't work.
If "Bundle display name" is not there in the info.plist,then add a row named "Bundle display name" and paste your appname .
Test this in your device. I think you are testing it in simulator and allowsImageEditing property Deprecated in iOS 3.1 so dont use it .
This can happen when there is animation not started on the main thread going on in parallel to kicking off the imagePickerController
If this is what you are running into you will likely see
<Warning>: CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces.
On your console log
I ran into it first by kicking off an activity indicator from a different thread (bug in its own right I know). But more insidiously this hit me due to loading a nib file in a background thread (which calls [CATransaction setDisableActions:] ... who knew)
Turning on CA_DEBUG_TRANSACTIONS in your scheme and then running in your simulator while tailing the system log (tail -f /var/log/system.log) is really the best way to find out the specific culprit.
Try this...
dispatch_async(dispatch_get_current_queue(), ^(void){
imagePicker.sourceType =
UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
} ) ;
While it could be an issue that depends on many factor, as shown from the successful solutions provided by other members, I think it's worth mentioning the fact that the user might have denied permissions for camera usage (Under Privacy->Camera->Your application) and thus the camera shows, but displays a black preview screen. It just happened to me, and it depended from a bug in the early development stage in which that question was never seen by the user because of overlapping alerts.
When you're creating the UIImagePickerController change the cameraOverlayView to nil. It worked like a charm for me.
self.imagePickerController.cameraOverlayView = nil;
And that should be it.
Please check [UIApplication sharedApplication].keyWindow.frame

Resources