Edit about Realm: I wonder if this has something to do with Realm? I always fetch data, sometimes multiple times in the pushed view controller, and sometimes also execute write transaction in the original controller. This write is not necessary for the freeze though, happens also when there's no write. I don't see anything else which could be causing this weird behaviour. In instruments using time profilers, during the app freeze there's no activity except some very short calls to some Realm getters, which are done in relatively long intervals. First question here, can Realm be responsible for the behaviour I'm describing, if yes how do I fix or at least confirm this?
//////////////////////////
My app freezes sometimes before a transition (push in navigation controller). I tap on a button, which triggers a segue programatically, where I set some initial data in the new controller. The app freezes exactly when tapping the button. The other controller's view seems to load (I was able to see a part of an animation that is executed by it), but that's it. There's no transition.
If I press home on the device, and open the app again, I'm able to advance a little step, i.e. it shows the pushed controller, as it should be, but on the next action it freezes again. Each time I press home and reopen I'm able to do exactly 1 action (tapping a button, etc.), which is processed correctly, and them it becomes unresponsive again.
I have paused the debugger to see the thread activity but I don't see anything suspicious (see screens). Not sure though. CPU shows 0% and memory stable at 20,4mb. This is after the first freeze:
Then I press home and open again, this is after the second freeze:
The code is too complex to be posted here, and creating a small example where this bug can be reproduced would be very time consuming, since it happens very rarely and I have no clue what could cause it. I tried writing UI tests where I repeat this action hundreds of times and couldn't reproduce it!
Any hints? How can I debug this further? Is there maybe something I can do with lldb console to get more information? What kind of issue causes app freezing like this?
Testing with a device (iPhone 6), iOS 9, also happened with iOS 8.
Edit: After pressing home and re-opening the app about 10 times (and do 1 action at a time) it just started working again.
Edit 2: I also checked the logs of the device, this is displayed frequently (not only when the app is frozen):
Error Domain=NSOSStatusErrorDomain Code=-25299 "duplicate item O,genp,(...)
but this seems to be keychain related and not responsible for this.
I also added some logs, and it seems to get stuck between viewWillAppear
and viewDidAppear
. It prints the last line in viewWillAppear
and it doesn't print the first line in viewDidAppear
.
Edit 3: So I'm now checking with instruments, and in one case the app freeze also froze my mac!! Until I was able to pause instruments. This was with CPU activity and Heap instruments. But I don't see anything suspicious in instruments neither! Leaks, etc. there are some small ones but nothing which should be causing this bug, since it happens sometimes very quickly when the there are not even 10mb. Time profiler also looks ok, while the app is not responsive there's nothing, except some very short calls to Realm database in relatively long intervals. Curious is that after some seconds in this state, instruments just stop recording. The app is still visible on the iPhone.
Aucun commentaire:
Enregistrer un commentaire