[TIMOB-25391] iOS: TiUITable crashes app with a Zombie
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-08-24T17:30:06.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.5.0 |
Components | iOS |
Labels | TableView, ios |
Reporter | Uriel Lizama |
Assignee | Hans Knöchel |
Created | 2017-10-13T23:06:39.000+0000 |
Updated | 2018-11-01T01:53:27.000+0000 |
Description
I'm using Titanium SDK 6.2.2.GA with Xcode 9 and iOS 11.
I'm testing the app with the new SDK and Xcode and I noticed that my app started crashing a lot. After some debugging I was able to see that the crash was happening when I close a Window that has a TableView with data binding.
I ran the app using Instruments with the Zombie profile and the crash is happening because is finding a zombie in the
TiUITableView dealloc
on this line:
[headerViewProxy setProxyObserver:nil];
I'm also getting crashes on this line:
[footerViewProxy setProxyObserver:nil];
My app crashes at least 1 of 3 times when closing windows that have TableViews.
Hello, your description is not clear "Instruments with the Zombie profile and the crash is happening because is finding a zombie in the"??!!. Send us a sample project that regenerates the issue. Thanks.
This sounds like a possible regression from [this commit](https://github.com/appcelerator/titanium_mobile/commit/ce57ad9044368066260b879fd7657ba6279f9768#diff-2284f41c2b88680b145a949a6972d02e) but it's since 6.1.0 already, so I am wondering why this occurs on 6.2.2 only for you. Moving over. Please also provide a minimal test-case that reproduces the issue, if possible!
I'll isolate the controller in my app that's triggering this behavior and I'll post it. Hans, I see the ticket you are referencing, and indeed it looks like the same behavior, and it crashes with the same logs, which makes me wonder why it would be ignoring the if statement:
That's what I am wondering as well. I think it's not nil, but the memory has already been given away at that point, which would also explain the zombie-state. I'll investigate it further once the test-case is ready, thank you for catching this! *EDIT*: I am unable to reproduce it with a simple table inside a window that is closed. It has a footer-view and some rows, but the error isn't triggered. Can you try the following (by replacing it in your SDK):
Hans, I did the patch with the code you gave me, and though it didn't fix the issue, it did move the error to a different place, but its still crashing. I was able to create a test app that correctly replicates the issue: http://baboonmedia.com/titanium/DebugApp.zip How to test: 1. Build the app 2. Click on the "Message Center" button to open a window with a TableView and binding. A list of rows should load 3. Close the window 4. Repeat 2 and 3 until the app crashes (usually within 3-5 window opens, though I've seen it happen after 20 attempts) I have the app crashing on an iPhone 6 Plus with iOS 11.0.3, and on the Simulator using an iPhone 8 with Xcode 9.
Any updates on this? Have you been able to reproduce with my test app?
I tested the app with the new 6.3.0.RC and the issue still persists. This is a big breaking issue for my apps, because it happens really often where the app becomes unusable, hopefully we can get more feedback to try and come up with a solution.
Hey Uriel, we didn't forget your issue! I tried it out with 35+ attempts in 6.2.2 and it does not break. I have main-thread enabled, not sure if that changes something. Will try more attempts. Please also note that (at least in your example), you do not initialize the infinite-loading properly, see this warning:
Please attach your full trace log of the crash as well, thx!
Hi Hans, Sorry for the late response. Today I started debugging and as it happened with you I wasn't able to make the app crash. The code hasn't changed and we are using the same SDK, so it doesn't make sense for it to stop crashing suddenly. Since I started debugging this issue I had a gut feeling that we might be encountering a "rush" issue, maybe if we closed the window at the same time as the data binding tried to load the views it will then crash. What I did to test this is: 1. I added a couple of lines so I don't have to be clicking buttons like a mad man :D Please edit the following files: *index.js* Add the following interval:
*tableWindow.js* On line 100 append the date to the request params:
On the open() function add a timeout to automatically close the window:
With these changes now the app will automatically open and close the message window. 2. Once I did this, the app was able to open/close the window without any issues for dozens and dozens of times. So, what I did is that I enabled the Network Link Conditioner, so that the data loads slower: https://www.natashatherobot.com/simulate-bad-network-ios-simulator/ I used the "Very Bad Network Profile". And done, the app crashes very often. My current theory is that right now our server is responding very quick, so the data loads and the tableviews are created before we even have a chance to close the window. When we setup a slow connection, we increase the possibility of this rush case to come in. Here is the output I get from lldb:
Let me know if you are able to make the app crash now. PS: The infiniteScroll is initialized on the script, that warning shows regardless.
I don't know if this is related to the same issue. I have another app that started crashing with the latest SDK as well *6.2.2.GA*. The crash happens when I open a window with a TableView, close it, and then open a different window with another TableView. The crash happens constantly, and only when I open and close windows with different tableviews. Here is the lldb log:
I don't know if I should open a new ticket about, but since it seems to be happening with dealloc as well on TableViews, I'm thinking it might be related.
Ok, let's get this started. First of all: The above is the same issue. Then: Can you try to revert [this PR](https://github.com/appcelerator/titanium_mobile/pull/8758/files) locally and see if it still crashes? Finally: Did you see crashes without data-binding? I'd like to know if that one caused it or a previous one. In the mean-time, I'll try to get an actual crash reproduced.
Ok, if I remove the following lines:
The bug doesn't appear, I tested by opening and closing the window 100 times without a crash. If I add the lines back, I get a crash within the first 10 opens. Next I'm doing the test without the data binding.
Ok, so I can't reproduce the bug on a Table without data binding. And I expected this, more coming with the fact that to be able to reproduce the bug consistently I needed not only to have data binding, but to also have poor connection so that the binding could still continue while trying to destroy the Window. What do you think?
Yes, that is correct. It might be a race-condition happening because the requests still pends and completes when the window is already closed. In that case, the requests need to ensure to be cancelled when the window is closed. I think that will resolve all issues, can you confirm that? Moving out of 7.0.0.
I am having this same problem after moving to Appcelerator 7.0.0 and Xcode 9.2. How do I accomplish this: "requests need to ensure to be cancelled when the window is closed"
I am only seeing this problem in the simulator. Is that the case for you as well? Below is the crash log and the crash in Xcode is showing EXC_BAD_ACCESS on this line in TiUITableView.m: [headerViewProxy setProxyObserver:nil];
This is a critical issue for us to upgrade to Appcelerator 7.0 and Xcode 9.
PR: https://github.com/appcelerator/titanium_mobile/pull/10199 Test-Case: See TIMOB-24320 for details, since we didn't really have any isolated one here.
*Closing ticket.* Verified fix with SDK version:
7.4.0.v20180820034952
. No crashes seen with the test case provided by [~hknoechel]. *Test Environment*I am seeing this problem in Xcode 10.1 and TI SDK 7.4.1 and testing it on iPhone 6 (v12.1)
This is in TiUITableView.m if (footerViewProxy != nil) { [footerViewProxy setProxyObserver:nil]; [[self proxy] forgetProxy:footerViewProxy]; footerViewProxy = nil; } Getting error: Thread 1: EXC_BAD_ACCESS (code=1, address=0x10)
I am seeing this problem in Xcode 10.1 and TI SDK 7.4.1 and testing it on iPhone 6 (v12.1) This is in TiUITableView.m if (footerViewProxy != nil) { [footerViewProxy setProxyObserver:nil]; [[self proxy] forgetProxy:footerViewProxy]; footerViewProxy = nil; } Getting error: Thread 1: EXC_BAD_ACCESS (code=1, address=0x10)
I commented the following lines as suggested by "Uriel Lizama", in my local copy on my machine and my app worked without any crash. TiUITableView.m file: /* if (headerViewProxy != nil) { [headerViewProxy setProxyObserver:nil]; [[self proxy] forgetProxy:headerViewProxy]; headerViewProxy = nil; } if (footerViewProxy != nil) { [footerViewProxy setProxyObserver:nil]; [[self proxy] forgetProxy:footerViewProxy]; footerViewProxy = nil; } */