Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24040] iOS: Set backgroundImage : "'' for TI.UI.VIEW cause app crash After SDK 5.5.0.GA

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2016-10-17T08:24:05.000+0000
Affected Version/sRelease 5.5.0, Release 5.5.1
Fix Version/sRelease 6.0.0
ComponentsiOS
Labelsbackgroundimage, regression
ReporterShuo Liang
AssigneeHans Knöchel
Created2016-10-15T07:33:57.000+0000
Updated2016-10-20T20:40:57.000+0000

Description

Reproduce

1. Create a default classic mobile project 2. Put attached two test code in it. 3. Run the app on iOS 10 device or simulator with SDK 5.5.1.GA 4. After the app running, click the open button. second window will open. 5. Click the close button, second window will close. 6. Click the open button again will cause the crash.

Crash code

[ERROR] :  The application has crashed with an uncaught exception 'NSRangeException'.
[INFO] :   SecondWindow opening
[ERROR] :  Reason:
[ERROR] :  *** -[__NSCFString substringFromIndex:]: Index 179 out of bounds; string length 178
[ERROR] :  Stack trace:
[ERROR] :  
[ERROR] :  0   CoreFoundation                      0x0000000111691333 __exceptionPreprocess + 147
[ERROR] :  1   libobjc.A.dylib                     0x0000000110c6021e objc_exception_throw + 48
[ERROR] :  2   CoreFoundation                      0x00000001116fa265 +[NSException raise:format:] + 197
[ERROR] :  3   Foundation                          0x000000010c2f31ae -[NSString substringFromIndex:] + 126
[ERROR] :  4   AppTest8                            0x000000010aad89e7 +[TiUtils loadAppResource:] + 279
[ERROR] :  5   AppTest8                            0x000000010ac00cf1 -[LocalProtocolHandler startLoading] + 337
[ERROR] :  6   CFNetwork                           0x000000010eb801b2 ___ZN16CFURLProtocol_NS28_protocolInterface_startLoadEPK20_CFCachedURLResponse_block_invoke + 307
[ERROR] :  7   libdispatch.dylib                   0x0000000113ca612e _dispatch_client_callout + 8
[ERROR] :  8   libdispatch.dylib                   0x0000000113c885b1 _dispatch_block_invoke_direct + 349
[ERROR] :  9   CFNetwork                           0x000000010ea4ceac _ZN19RunloopBlockContext13_invoke_blockEPKvPv + 24
[ERROR] :  10  CoreFoundation                      0x00000001115e2014 CFArrayApplyFunction + 68
[ERROR] :  11  CFNetwork                           0x000000010ea4cda5 _ZN19RunloopBlockContext7performEv + 137
[ERROR] :  12  CFNetwork                           0x000000010ea4cc3e _ZN17MultiplexerSource7performEv + 282
[ERROR] :  13  CFNetwork                           0x000000010ea4ca60 _ZN17MultiplexerSource8_performEPv + 72
[ERROR] :  14  CoreFoundation                      0x0000000111636311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
[ERROR] :  15  CoreFoundation                      0x000000011161b59c __CFRunLoopDoSources0 + 556
[ERROR] :  16  CoreFoundation                      0x000000011161aa86 __CFRunLoopRun + 918
[ERROR] :  17  CoreFoundation                      0x000000011161a494 CFRunLoopRunSpecific + 420
[ERROR] :  18  CFNetwork                           0x000000010eced082 _ZL27_privateRunloopEmulationSetPv + 258
[ERROR] :  19  libsystem_pthread.dylib             0x000000011404c99d _pthread_body + 131
[ERROR] :  20  libsystem_pthread.dylib             0x000000011404c91a _pthread_body + 0
[ERROR] :  21  libsystem_pthread.dylib             0x000000011404a351 thread_start + 13
[ERROR] :  
[ERROR] :  2016-10-15 15:32:36.719 AppTest8[36595:139152] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSCFString substringFromIndex:]: Index 179 out of bounds; string length 178'
[ERROR] :  *** First throw call stack:
[ERROR] :  (
[ERROR] :  	0   CoreFoundation                      0x000000011169134b __exceptionPreprocess + 171
[ERROR] :  	1   libobjc.A.dylib                     0x0000000110c6021e objc_exception_throw + 48
[ERROR] :  	2   CoreFoundation                      0x00000001116fa265 +[NSException raise:format:] + 197
[ERROR] :  	3   Foundation                          0x000000010c2f31ae -[NSString substringFromIndex:] + 126
[ERROR] :  	4   AppTest8                            0x000000010aad89e7 +[TiUtils loadAppResource:] + 279
[ERROR] :  	5   AppTest8                            0x000000010ac00cf1 -[LocalProtocolHandler startLoading] + 337
[ERROR] :  	6   CFNetwork                           0x000000010eb801b2 ___ZN16CFURLProtocol_NS28_protocolInterface_startLoadEPK20_CFCachedURLResponse_block_invoke + 307
[ERROR] :  	7   libdispatch.dylib                   0x0000000113ca612e _dispatch_client_callout + 8
[ERROR] :  	8   libdispatch.dylib                   0x0000000113c885b1 _dispatch_block_invoke_direct + 349
[ERROR] :  	9   CFNetwork                           0x000000010ea4ceac _ZN19RunloopBlockContext13_invoke_blockEPKvPv + 24
[ERROR] :  	10  CoreFoundation                      0x00000001115e2014 CFArrayApplyFunction + 68
[ERROR] :  	11  CFNetwork                           0x000000010ea4cda5 _ZN19RunloopBlockContext7performEv + 137
[ERROR] :  	12  CFNetwork                           0x000000010ea4cc3e _ZN17MultiplexerSource7performEv + 282
[ERROR] :  	13  CFNetwork                           0x000000010ea4ca60 _ZN17MultiplexerSource8_performEPv + 72
[ERROR] :  	14  CoreFoundation                      0x0000000111636311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
[ERROR] :  	15  CoreFoundation                      0x000000011161b59c __CFRunLoopDoSources0 + 556
[ERROR] :  	16  CoreFoundation                      0x000000011161aa86 __CFRunLoopRun + 918
[ERROR] :  	17  CoreFoundation                      0x000000011161a494 CFRunLoopRunSpecific + 420
[ERROR] :  	18  CFNetwork                           0x000000010eced082 _ZL27_privateRunloopEmulationSetPv + 258
[ERROR] :  	19  libsystem_pthread.dylib             0x000000011404c99d _pthread_body + 131
[ERROR] :  	20  libsystem_pthread.dylib             0x000000011404c91a _pthread_body + 0
[ERROR] :  	21  libsystem_pthread.dylib             0x000000011404a351 thread_start + 13
[ERROR] :  )
[ERROR] :  libc++abi.dylib: terminating with uncaught exception of type NSException

Note

1. Same code is working well on TISDK 5.2.2.GA 2. If you comment out line 20 of ApplicationWindow.js (like following), it will working well on SDK 5.5.0 and 5.5.1.GA
//backgroundImage : ' ',
3. If there is webview in second page, it will not crash at all.

Attachments

FileDateSize
app.js2016-10-15T07:33:55.000+0000644
ApplicationWindow.js2016-10-15T07:33:55.000+000022438

Comments

  1. Hans Knöchel 2016-10-15

    Ok, here is the thing: We fixed unbalanced backgroundImage calls in Ti.UI.View in recent Titanium releases by using an internal utility method. And because providing an empty string (rather than an image or null), the empty string has been handled as an url and caused the crash by searching for the image cash in the second call to that path. With this PR, we check for empty strings manually and prevent it from being cached then (just return nil). Anyway, if the customer wants a fix for their current SDK, they can just replace the "" with null or just leave out the property if they don't set it. Even when they set it later, it is not required to set it with empty values before, our SDK will know how to handle it. PR (master): https://github.com/appcelerator/titanium_mobile/pull/8517 PR (6_0_X): https://github.com/appcelerator/titanium_mobile/pull/8518
  2. Chee Kiat Ng 2016-10-17

    APPROVED
  3. Abir Mukherjee 2016-10-20

    The bug appears to be resolved. I tested it with this environment: NPM Version: 2.15.9 Node Version: 4.5.0 Mac OS: 10.11.6 Appc CLI: 5.5.1 Appc CLI NPM: 4.2.7 Titanium SDK version: 6.0.0.v20161019091022 Appcelerator Studio, build: 4.8.0.201610171310 Xcode 8.0 GM Firstly, I reproduced the bug using the sample scripts in the description with SDK 5.5.1. I then tested with SDK 6.0.0. I followed the steps; I clicked on "open", then "close" in the second window, and then "open" again. The app did not crash, and instead went back to the second window. I tried this on the simulator and on an iOS 10 device.

JSON Source