Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre iOS 13 devices fail to deallocate BSImagePicker after it has been dismissed #320

Open
gams95 opened this issue Jan 11, 2021 · 5 comments

Comments

@gams95
Copy link

gams95 commented Jan 11, 2021

I notice that when BSImagePicker was dismissed, BSImagePicker does not deallocate even though the presentingViewController has bee deallocated (deinit). This only happens on devices running pre iOS 13. As a workaround, i changed the modalPresentationStyle of BSImagePicker to .currentContext Even though it manages to fix this issue, however i do not know if this is the right way of fixing this issue. Any thoughts on this?

@mikaoj
Copy link
Owner

mikaoj commented Jan 11, 2021

Nice, sounds like it is related to #271.

Have you tried any of the other presentation styles too and found that it is only .currentContext that works?

@gams95
Copy link
Author

gams95 commented Jan 11, 2021

In my implementation:

  1. I set imagePickerController as optional in my viewController.
  2. I don't use the closure and implement the ImagePickerDelegate on my own viewcontroller
  3. Before dismissing, i set the imagePickerController as nil

Based on above implementation, only .currentContext deallocate properly after the viewcontroller has been dismissed.

@nesteralready
Copy link

nesteralready commented Nov 2, 2021

iOS 14.7 same issue. I tried to fix by myself, but the only thing that I understood - it's the problem in method "presentImagePicker" cause after removing it and presenting just like " vc.present(imagePicker, animated: true)" memory leak is never happened.

@tiper
Copy link

tiper commented May 25, 2022

The issue seems to be caused by the ImagePickerController when on the viewDidLoad it sets the presentationController.delegate to self. However, invoking imagePicker.presentationController before calling presentImagePicker seems to fix the issue.

let imagePicker = ImagePickerController()
...
<image picker configurations here>
...
_ = imagePicker.presentationController
controller.presentImagePicker(imagePicker, animated: true, select: nil, deselect: nil, cancel: nil, finish: nil, completion: nil)

@jdleung
Copy link

jdleung commented Oct 31, 2023

The issue seems to be caused by the ImagePickerController when on the viewDidLoad it sets the presentationController.delegate to self. However, invoking imagePicker.presentationController before calling presentImagePicker seems to fix the issue.

let imagePicker = ImagePickerController()
...
<image picker configurations here>
...
_ = imagePicker.presentationController
controller.presentImagePicker(imagePicker, animated: true, select: nil, deselect: nil, cancel: nil, finish: nil, completion: nil)

It doesn't work on my end, the memory consumption still increases every time when clicking into imagePicker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants