UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Project 13 - Simulator issues and app crashes

Forums > 100 Days of SwiftUI

Hello everyone,

I am facing a few issues in project 13. I tried to investigate the causes for two days without any success, so I hope someone could point me in the right direction.

  1. In the technique part of the project, the selected picture in the simulator is blacked out as soon as I apply the sepia tone filter. Everything works fine if I run it on the device, but I can't find a way to show the filtered picture in the simulator
  2. When I added the slider to control the filter intensity the UI became very sluggish on the device. The slider moves really slowly and changes to the filter intensity take a long time to reflect on the output image.
  3. Usually, after picking a few different pictures and/or selecting different filters, the app becomes irresponsive and crashes with the debugger message "Terminated due to memory issue".

I believe I have followed the tutorial instructions closely and my code is identical to Paul's, so I am wondering if anyone faced similar issues on this project. I am using XCode 11.6 and iOS 13.6 on an iPhone Xs Max.

I also tried to use Instruments for the first time to try and make sense of that debugger message. I have never used any profiling tools so I am bit lost but this is what I found out:

  1. If I launch the app and open the image picker and then click cancel, I get no memory leaks.
  2. As soon as I select a picture, I get 4 leaked objects and all but one malloc have a reference to UIImagePickerControllerInfoDictionaryFromPhotoPickerInfoDictionary as shown on the screenshot below.
  3. If I keep picking images, the same leaks keep increasing.
  4. If I start moving the slider, the effect intensity is slowly updated and after a few moments the app crashes completely.

I am about to start from scratch again even though I check my code multiple times, but if anyone faced similar problems, it would be great to know.

Thanks in advance.

3      

Kind of similar problem when I try to slide the slider button then my app crashes with

** First throw call stack: (0x19e26d114 0x1b1b09cb4 0x19e17d9b8 0x1a0ae48ac 0x19e26f758 0x19e2716cc 0x1a0ab691c 0x1a044e5bc 0x1a044e900 0x1a095bfe8 0x1a047634c 0x1a044cd94 0x1a0af1594 0x1a0af3118 0x1a0ace4fc 0x1a0b5076c 0x1a0b54f0c 0x1a0b4c1cc 0x19e1ed240 0x19e1ed140 0x19e1ec488 0x19e1e6a40 0x19e1e6200 0x1b4363598 0x1a0aafbcc 0x1a0ab51a0 0x1b0eb54ec 0x1029cb214 0x1029cb18c 0x1029cb258 0x19dec5588) libc++abi.dylib: terminating with uncaught exception of type NSException *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Project13.ViewController intensitychanged:]: unrecognized selector sent to instance 0x102f0c520' terminating with uncaught exception of type NSException (lldb)

3      

A couple of things:

1- The simulator tends to be more sluggish, so that's to be expected.

2- Without seeing the code, we can not provide answers. So if you have your code on github (or similar) that would certainly help.

This link might help : https://medium.com/better-programming/diagnose-memory-leaks-using-xcode-instruments-5692a6458020

3      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.