Crash when app is asking a permission to access photos, and Cancel to dismiss not working #67

Closed
vburojevic opened this Issue Nov 17, 2013 · 15 comments

Comments

Projects
None yet
2 participants
@vburojevic

When ELCImagePickerController is opened for a first time, it asks for a permission to access photos, and then it crashes. After you accept and compile for a second time, it does not crash.

Cancel to dismiss ELCImagePickerController is not working, I have set the delegate.

@jvanmetre

This comment has been minimized.

Show comment Hide comment
@jvanmetre

jvanmetre Nov 18, 2013

Contributor

Can you attach a backtrace of the crash?
When you set the delegate, it is up to the delegate to implement elcImagePickerControllerDidCancel: and dismiss the ELCImagePickerController, in the opposite way of how it was presented.
This could be as simple as:

- (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
Contributor

jvanmetre commented Nov 18, 2013

Can you attach a backtrace of the crash?
When you set the delegate, it is up to the delegate to implement elcImagePickerControllerDidCancel: and dismiss the ELCImagePickerController, in the opposite way of how it was presented.
This could be as simple as:

- (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
@vburojevic

This comment has been minimized.

Show comment Hide comment
@vburojevic

vburojevic Nov 18, 2013

Regarding the crash, I just get EXC_BAD_ACCESS when the dialog to permit
the app to access photos appears. What is weird is that if I approve access
to photos after the crash, and recompile, it will work just fine.

Regarding the dismiss issue, yes, my code looks just like yours, and I have
set the delegate. The issue with dismiss started happening when I updated
the ELCImagePickerController to the latest version.

Crash issue is present before newest version.

EDIT (Crash issue)

With NSZombie enabled, I get:
<PGThumbsController: 0xcddefc0>.
2013-11-18 19:04:35.120 Photo Locker[907:70b] *** -[PGThumbsController respondsToSelector:]: message sent to deallocated instance 0xcddefc0

PGThumbsController is a view controller from which I create the ELCImagePickerController.

Code looks like this:

  • (IBAction)importPhotos:(id)sender {
    ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] init];
    elcPicker.delegate = self;

    //Present modal controller
    [self presentViewController: elcPicker animated: TRUE completion:nil];

    //Release controllers
    [elcPicker release];
    }

Tested on device and simulator, on iOS 6 and 7. ARC not used in project.

On Mon, Nov 18, 2013 at 5:49 PM, jvanmetre notifications@github.com wrote:

Can you attach a backtrace of the crash?
When you set the delegate, it is up to the delegate to implement
elcImagePickerControllerDidCancel: and dismiss the
ELCImagePickerController, in the opposite way of how it was presented.
This could be as simple as:

  • (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker{
    [self dismissViewControllerAnimated:YES completion:nil];}


Reply to this email directly or view it on GitHubhttps://github.com/B-Sides/ELCImagePickerController/issues/67#issuecomment-28715134
.

Regarding the crash, I just get EXC_BAD_ACCESS when the dialog to permit
the app to access photos appears. What is weird is that if I approve access
to photos after the crash, and recompile, it will work just fine.

Regarding the dismiss issue, yes, my code looks just like yours, and I have
set the delegate. The issue with dismiss started happening when I updated
the ELCImagePickerController to the latest version.

Crash issue is present before newest version.

EDIT (Crash issue)

With NSZombie enabled, I get:
<PGThumbsController: 0xcddefc0>.
2013-11-18 19:04:35.120 Photo Locker[907:70b] *** -[PGThumbsController respondsToSelector:]: message sent to deallocated instance 0xcddefc0

PGThumbsController is a view controller from which I create the ELCImagePickerController.

Code looks like this:

  • (IBAction)importPhotos:(id)sender {
    ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] init];
    elcPicker.delegate = self;

    //Present modal controller
    [self presentViewController: elcPicker animated: TRUE completion:nil];

    //Release controllers
    [elcPicker release];
    }

Tested on device and simulator, on iOS 6 and 7. ARC not used in project.

On Mon, Nov 18, 2013 at 5:49 PM, jvanmetre notifications@github.com wrote:

Can you attach a backtrace of the crash?
When you set the delegate, it is up to the delegate to implement
elcImagePickerControllerDidCancel: and dismiss the
ELCImagePickerController, in the opposite way of how it was presented.
This could be as simple as:

  • (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker{
    [self dismissViewControllerAnimated:YES completion:nil];}


Reply to this email directly or view it on GitHubhttps://github.com/B-Sides/ELCImagePickerController/issues/67#issuecomment-28715134
.

@jvanmetre

This comment has been minimized.

Show comment Hide comment
@jvanmetre

jvanmetre Nov 18, 2013

Contributor

Did you make sure to set -fobjc-arc on the files for ELCImagePicker?
If your project doesn't use arc, the ELCImagePicker newest versions do, and that could be your problem.

Contributor

jvanmetre commented Nov 18, 2013

Did you make sure to set -fobjc-arc on the files for ELCImagePicker?
If your project doesn't use arc, the ELCImagePicker newest versions do, and that could be your problem.

@vburojevic

This comment has been minimized.

Show comment Hide comment
@vburojevic

vburojevic Nov 18, 2013

Thanks, I will try that when I get back home and update you. :)
What about the dismiss issue, can it be ARC related too?

On Mon, Nov 18, 2013 at 7:22 PM, jvanmetre notifications@github.com wrote:

Did you make sure to set -fobjc-arc on the files for ELCImagePicker?
If your project doesn't use arc, the ELCImagePicker newest versions do,
and that could be your problem.


Reply to this email directly or view it on GitHubhttps://github.com/B-Sides/ELCImagePickerController/issues/67#issuecomment-28723523
.

Thanks, I will try that when I get back home and update you. :)
What about the dismiss issue, can it be ARC related too?

On Mon, Nov 18, 2013 at 7:22 PM, jvanmetre notifications@github.com wrote:

Did you make sure to set -fobjc-arc on the files for ELCImagePicker?
If your project doesn't use arc, the ELCImagePicker newest versions do,
and that could be your problem.


Reply to this email directly or view it on GitHubhttps://github.com/B-Sides/ELCImagePickerController/issues/67#issuecomment-28723523
.

@jvanmetre

This comment has been minimized.

Show comment Hide comment
@jvanmetre

jvanmetre Nov 18, 2013

Contributor

That would be my guess as well. That it also is related to ARC.

Contributor

jvanmetre commented Nov 18, 2013

That would be my guess as well. That it also is related to ARC.

@vburojevic

This comment has been minimized.

Show comment Hide comment
@vburojevic

vburojevic Nov 18, 2013

Ok, thanks! I will get back at you!

On Mon, Nov 18, 2013 at 7:24 PM, jvanmetre notifications@github.com wrote:

That would be my guess as well. That it also is related to ARC.


Reply to this email directly or view it on GitHubhttps://github.com/B-Sides/ELCImagePickerController/issues/67#issuecomment-28723729
.

Ok, thanks! I will get back at you!

On Mon, Nov 18, 2013 at 7:24 PM, jvanmetre notifications@github.com wrote:

That would be my guess as well. That it also is related to ARC.


Reply to this email directly or view it on GitHubhttps://github.com/B-Sides/ELCImagePickerController/issues/67#issuecomment-28723729
.

@vburojevic

This comment has been minimized.

Show comment Hide comment
@vburojevic

vburojevic Nov 18, 2013

I have checked the settings.
I've added ELCImagePickerController via CocoaPods, the compiler flags are set to ARC (-fobjc-arc), so this is not a problem.

I have checked the settings.
I've added ELCImagePickerController via CocoaPods, the compiler flags are set to ARC (-fobjc-arc), so this is not a problem.

@jvanmetre

This comment has been minimized.

Show comment Hide comment
@jvanmetre

jvanmetre Nov 18, 2013

Contributor

Ahh... I see what the issue is now.... set the imagePickerDelegate, not the delegate... Since ELCImagePickerController extends UINavigationController, the old code was improperly overriding the delegate of the UINavigationController, so I changed it to be imagePickerDelegate instead.

Contributor

jvanmetre commented Nov 18, 2013

Ahh... I see what the issue is now.... set the imagePickerDelegate, not the delegate... Since ELCImagePickerController extends UINavigationController, the old code was improperly overriding the delegate of the UINavigationController, so I changed it to be imagePickerDelegate instead.

@vburojevic

This comment has been minimized.

Show comment Hide comment
@vburojevic

vburojevic Nov 18, 2013

Thank you very much! Crash issue is resolved by setting the imagePickerDelegate, not delegate!

Regarding the dismiss issue, I have changed the code from:

  • (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker
    {
    [self dismissViewControllerAnimated:YES completion:nil];
    }

to

  • (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker
    {
    [picker dismissViewControllerAnimated:YES completion:nil];
    }

Do you know why dismissing the view controller with picker, not with self, is working?
Before the new version it worked with self.

Thank you very much! Crash issue is resolved by setting the imagePickerDelegate, not delegate!

Regarding the dismiss issue, I have changed the code from:

  • (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker
    {
    [self dismissViewControllerAnimated:YES completion:nil];
    }

to

  • (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker
    {
    [picker dismissViewControllerAnimated:YES completion:nil];
    }

Do you know why dismissing the view controller with picker, not with self, is working?
Before the new version it worked with self.

@jvanmetre

This comment has been minimized.

Show comment Hide comment
@jvanmetre

jvanmetre Nov 18, 2013

Contributor

It should still dismiss fine when using [self dismissViewControllerAnimated:], That's what the demo code does. :/

Contributor

jvanmetre commented Nov 18, 2013

It should still dismiss fine when using [self dismissViewControllerAnimated:], That's what the demo code does. :/

@vburojevic

This comment has been minimized.

Show comment Hide comment
@vburojevic

vburojevic Nov 18, 2013

Ok, I will check my code, maybe it has some issues in the view hierarchy.
Thanks again for resolving the crash issue and for swift replies!

EDIT: Dismiss works fine now too after the delegate is set correctly, after rebuilding the project.

Ok, I will check my code, maybe it has some issues in the view hierarchy.
Thanks again for resolving the crash issue and for swift replies!

EDIT: Dismiss works fine now too after the delegate is set correctly, after rebuilding the project.

@vburojevic vburojevic closed this Nov 18, 2013

@vburojevic

This comment has been minimized.

Show comment Hide comment
@vburojevic

vburojevic Nov 18, 2013

After further testing, I have discovered that when app is running for the first time, and the app asks for permission, Cancel to dismiss is not working. After recompiling the app (after the permissions are granted), Cancel to dismiss works just fine.

jvanmetre, do you have any idea why this is happening?

There is something wrong with the delegate when permission is asked from the app, but can't figure out what.

Current code:

  • (IBAction)importPhotos:(id)sender {
    ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] init];
    elcPicker.imagePickerDelegate = self;

    [self presentViewController:elcPicker animated:YES completion:nil];
    [elcPicker release];
    }

After further testing, I have discovered that when app is running for the first time, and the app asks for permission, Cancel to dismiss is not working. After recompiling the app (after the permissions are granted), Cancel to dismiss works just fine.

jvanmetre, do you have any idea why this is happening?

There is something wrong with the delegate when permission is asked from the app, but can't figure out what.

Current code:

  • (IBAction)importPhotos:(id)sender {
    ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] init];
    elcPicker.imagePickerDelegate = self;

    [self presentViewController:elcPicker animated:YES completion:nil];
    [elcPicker release];
    }

@vburojevic vburojevic reopened this Nov 18, 2013

@jvanmetre

This comment has been minimized.

Show comment Hide comment
@jvanmetre

jvanmetre Nov 18, 2013

Contributor

That is strange, and I can't seem to replicate it in the demo app.

Contributor

jvanmetre commented Nov 18, 2013

That is strange, and I can't seem to replicate it in the demo app.

@vburojevic

This comment has been minimized.

Show comment Hide comment
@vburojevic

vburojevic Nov 18, 2013

Me neither :(

What is strange is that I get this messages the second the dialog for approval shows (when Cancel stops working, before trying to hit Cancel, or anything else on the screen).

2013-11-18 23:40:36.974 Photo Locker[7220:70b] Warning: Attempt to dismiss from view controller <UINavigationController: 0xbca2e90> while a presentation or dismiss is in progress!
2013-11-18 23:40:36.977 Photo Locker[7220:70b] Warning: Attempt to present <UINavigationController: 0xbf6b1e0> on <UINavigationController: 0xbca2e90> while a presentation is in progress!
2013-11-18 23:40:36.979 Photo Locker[7220:941b] Memory Capacity of 228116 MiB
2013-11-18 23:40:36.980 Photo Locker[7220:941b] 173040 MiB Free memory available.
2013-11-18 23:40:36.981 Photo Locker[7220:70b] Unbalanced calls to begin/end appearance transitions for <PGThumbsController: 0xbe953b0>.

When I compile the second time, when Cancel to dismiss works, it dos not show these messages.

Any ideas?

Me neither :(

What is strange is that I get this messages the second the dialog for approval shows (when Cancel stops working, before trying to hit Cancel, or anything else on the screen).

2013-11-18 23:40:36.974 Photo Locker[7220:70b] Warning: Attempt to dismiss from view controller <UINavigationController: 0xbca2e90> while a presentation or dismiss is in progress!
2013-11-18 23:40:36.977 Photo Locker[7220:70b] Warning: Attempt to present <UINavigationController: 0xbf6b1e0> on <UINavigationController: 0xbca2e90> while a presentation is in progress!
2013-11-18 23:40:36.979 Photo Locker[7220:941b] Memory Capacity of 228116 MiB
2013-11-18 23:40:36.980 Photo Locker[7220:941b] 173040 MiB Free memory available.
2013-11-18 23:40:36.981 Photo Locker[7220:70b] Unbalanced calls to begin/end appearance transitions for <PGThumbsController: 0xbe953b0>.

When I compile the second time, when Cancel to dismiss works, it dos not show these messages.

Any ideas?

@vburojevic

This comment has been minimized.

Show comment Hide comment
@vburojevic

vburojevic Nov 19, 2013

Cancel bug was an error in my code, - (void)applicationWillResignActive:(UIApplication *)application dismissed all view controllers, which gets called when approval to access photos is shown, and that is why ELCImagePickerController was destroyed but not dismissed properly.

Cancel bug was an error in my code, - (void)applicationWillResignActive:(UIApplication *)application dismissed all view controllers, which gets called when approval to access photos is shown, and that is why ELCImagePickerController was destroyed but not dismissed properly.

@vburojevic vburojevic closed this Nov 19, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment