[TIMOB-24320] iOS: Removing a TableView with headerView may cause the app to crash
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2017-01-26T22:53:59.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.1.0 |
Components | iOS |
Labels | n/a |
Reporter | Shinya Kasatani |
Assignee | Hans Knöchel |
Created | 2017-01-17T15:12:00.000+0000 |
Updated | 2017-10-15T08:31:08.000+0000 |
Description
I have an app with TableView with headerView or footerView specified. When you add this view into ScrollableView and removing it afterwards, it causes the app to crash with SIGABRT. It happens on both simulator and the device.
Here is the crash log:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace OBJC, Code 0x1
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000180fd0d74 __abort_with_payload + 8
1 libsystem_kernel.dylib 0x0000000180fcd480 abort_with_payload_wrapper_internal + 100
2 libsystem_kernel.dylib 0x0000000180fcd41c abort_with_payload_wrapper_internal + 0
3 libobjc.A.dylib 0x0000000180a3bed8 _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 112
4 libobjc.A.dylib 0x0000000180a3be30 __objc_error + 0
5 libobjc.A.dylib 0x0000000180a4ecd4 weak_entry_insert(weak_table_t*, weak_entry_t*) + 0
6 libobjc.A.dylib 0x0000000180a542a8 objc_storeWeak + 328
7 UIKit 0x0000000187f097fc -[UIScrollView setDelegate:] + 336
8 UIKit 0x0000000187f357ec -[UITableView setDelegate:] + 368
9 App 0x000000010018518c -[TiUITableView tableView] (TiUITableView.m:0)
10 App 0x000000010018de88 __34-[TiUITableView proxyDidRelayout:]_block_invoke (TiUITableView.m:1750)
11 libdispatch.dylib 0x0000000180e8d200 _dispatch_call_block_and_release + 24
12 libdispatch.dylib 0x0000000180e8d1c0 _dispatch_client_callout + 16
13 libdispatch.dylib 0x0000000180e91d6c _dispatch_main_queue_callback_4CF + 1000
14 CoreFoundation 0x0000000181faff2c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
15 CoreFoundation 0x0000000181fadb18 __CFRunLoopRun + 1660
16 CoreFoundation 0x0000000181edc048 CFRunLoopRunSpecific + 444
17 GraphicsServices 0x0000000183962198 GSEventRunModal + 180
18 UIKit 0x0000000187ec72fc -[UIApplication _run] + 684
19 UIKit 0x0000000187ec2034 UIApplicationMain + 208
20 App 0x000000010010a4d8 main (main.m:30)
21 libdyld.dylib 0x0000000180ec05b8 start + 4
I guess this happens after the TiUITableView is dealloc'ed and the headerViewProxy is still alive at that time. The app doesn't crash when you call [headerViewProxy setProxyObserver:nil] from -[TiUITableView dealloc].
I have tried to create a simple example to describe this problem, but I have not successfully created one that reproduces the issue.
Attachments
File | Date | Size |
---|---|---|
tableview-fix.patch | 2017-01-17T15:10:26.000+0000 | 445 |
Hello, We need a sample code for us to verify the issue to apply a fix. Please provide one sample code that regenerates the issue. Thanks.
Hey [~kasatani], your proposal looks pretty good so far. either the delegate or the property observer is making problems, so when you nil it, it won't call the delegate and therefore don't crash. Good catch! Do you want to do a PR to the open source project yourself or should we do one? And [~sdarda] is right, we still need a demo-code, so our QE can validate the possible fix. Thx! *EDIT*: This does not happen with Ti.UI.ListView as far as I can see ([gist](https://gist.github.com/hansemannn/5bcf6b1b2fde58da387ca902ae1d5bd2)) *EDIT*: Same with Ti.UI.TableView, not reproducible ([gist](https://gist.github.com/hansemannn/a43b545566d064d308e3d111ddecdc8f))
PR: https://github.com/appcelerator/titanium_mobile/pull/8758 Test-Case (will not always throw without the fix, but with the fix, it will never):
Note: This test-case will trigger an add/remove loop, so we get more potential cases where it would crash.
[~kasatani] I added some more changes in https://github.com/appcelerator/titanium_mobile/pull/8758 additional to yours, can you validate that this is this fine?
Thanks for creating a PR! I have confirmed that this fixes the problem.
FR passed, using: MacOS 10.12 (16A323) Studio 4.8.1.201612050850 Ti SDK 6.1.0 Appc NPM 4.2.8 Appc CLI 6.1.0 Alloy 1.9.5 Xcode 8.2 (8C38) No crash encountered when adding or removing a tableview with a headerview. Tested using the provided test case (left running for over a minute) and manually adding and removing the views.
Verified in SDK 6.1.0.v20170126150653