Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24139] iOS: App is crashed if it contain Button with backgroundImage property (regression)

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2016-11-11T14:21:50.000+0000
Affected Version/sRelease 6.0.0
Fix Version/sRelease 6.0.0
ComponentsiOS
Labelsregression
ReporterQuang Pham
AssigneeHans Knöchel
Created2016-11-11T08:58:33.000+0000
Updated2016-11-11T19:19:21.000+0000

Description

Steps to reproduce: 1. Click Show window button 2. Click Back button 3. Click Show window button again => window is crashed. Remove the backgroundImage property of button, App is not crashed anymore. SDK: 6 RC 6.0.0.v20161101155110 IOS simulator + device iPhone 5C OSX 10.11.6

Attachments

FileDateSize
close3.png2016-11-11T14:12:32.000+00005673
test.zip2016-11-11T08:54:52.000+000010480672

Comments

  1. Ewan Harris 2016-11-11

    [~ptquang86] Thanks for the report! *This is a regression from 5.5.1.GA* I can reproduce this using OS: Mac OS X 10.11.6 Appc core: 6.0.0-69 Appc NPM: 4.2.8-9 Ti SDK: 6.0.0.v20161110183702 Xcode: 8.1 iOS 10.1 simulator
       var win2 = Titanium.UI.createWindow();
       
       var win1 = Titanium.UI.iOS.createNavigationWindow({
          window: win2
       });
       
       var win3 = Titanium.UI.createWindow();
       
       var button = Titanium.UI.createButton({
           title: 'Open Window'
       });
       button.addEventListener('click', function(){
           win1.openWindow(win3);
       });
       
       win2.add(button);
       var button2 = Titanium.UI.createButton({
           backgroundImage: 'assets/images/tab1.png'
       });
       
       win3.add(button2);
       win1.open();
       
       [ERROR] The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
       [ERROR] Reason:
       [ERROR] -[NSPathStore2 drawingStroke]: unrecognized selector sent to instance 0x6000002833e0
       [ERROR] Stack trace:
       [ERROR] 0   CoreFoundation                      0x000000011530f333 __exceptionPreprocess + 147
       [ERROR] 1   libobjc.A.dylib                     0x00000001148b521e objc_exception_throw + 48
       [ERROR] 2   CoreFoundation                      0x000000011537ef34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
       [ERROR] 3   CoreFoundation                      0x0000000115294c15 ___forwarding___ + 1013
       [ERROR] 4   CoreFoundation                      0x0000000115294798 _CF_forwarding_prep_0 + 120
       [ERROR] 5   UIKit                               0x000000011085d5cb UICheckForDrawingStyle + 39
       [ERROR] 6   CoreFoundation                      0x0000000115257666 __CFDictionaryApplyFunction_block_invoke + 22
       [ERROR] 7   CoreFoundation                      0x0000000115257620 CFBasicHashApply + 144
       [ERROR] 8   CoreFoundation                      0x0000000115257549 CFDictionaryApplyFunction + 185
       [ERROR] 9   UIKit                               0x000000011085d64b -[UIButton _hasDrawingStyle] + 49
       [ERROR] 10  UIKit                               0x000000011085a3b1 -[UIButton _isModernButton] + 86
       [ERROR] 11  UIKit                               0x0000000110864ffe -[UIButton _shouldDefaultToTemplatesForImageViewBackground:] + 25
       [ERROR] 12  UIKit                               0x000000011086505e -[UIButton _updateEffectsForImageView:background:] + 58
       [ERROR] 13  UIKit                               0x000000011085999a -[UIButton _didChangeFromIdiom:onScreen:traverseHierarchy:] + 104
       [ERROR] 14  UIKit                               0x000000011052a13f -[UIView(Internal) _didChangeFromIdiomOnScreen:traverseHierarchy:] + 181
       [ERROR] 15  UIKit                               0x000000011052969b -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1713
       [ERROR] 16  UIKit                               0x00000001105f2331 -[UIControl _didMoveFromWindow:toWindow:] + 68
       [ERROR] 17  UIKit                               0x000000011052931d -[UIView(Internal) _didMoveFromWindow:toWindow:] + 819
       [ERROR] 18  UIKit                               0x000000011052931d -[UIView(Internal) _didMoveFromWindow:toWindow:] + 819
       [ERROR] 19  UIKit                               0x000000011052931d -[UIView(Internal) _didMoveFromWindow:toWindow:] + 819
       [ERROR] 20  UIKit                               0x000000011051c6b4 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 151
       [ERROR] 21  UIKit                               0x000000011051c5a2 -[UIView(Hierarchy) _postMovedFromSuperview:] + 857
       [ERROR] 22  UIKit                               0x000000011052c2eb -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1982
       [ERROR] 23  UIKit                               0x000000011051a7a1 -[UIView(Hierarchy) addSubview:] + 838
       [ERROR] 24  UIKit                               0x0000000110457869 -[_UIParallaxDimmingView didMoveToWindow] + 180
       [ERROR] 25  UIKit                               0x00000001105296f1 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1799
       [ERROR] 26  UIKit                               0x000000011052931d -[UIView(Internal) _didMoveFromWindow:toWindow:] + 819
       [ERROR] 27  UIKit                               0x000000011051c6b4 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 151
       [ERROR] 28  UIKit                               0x000000011051c5a2 -[UIView(Hierarchy) _postMovedFromSuperview:] + 857
       [ERROR] 29  UIKit                               0x000000011052c2eb -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1982
       [ERROR] 30  UIKit                               0x000000011051a7a1 -[UIView(Hierarchy) addSubview:] + 838
       [ERROR] 31  UIKit                               0x00000001104524e3 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke_2 + 2604
       [ERROR] 32  UIKit                               0x00000001105246e6 +[UIView(Animation) performWithoutAnimation:] + 90
       [ERROR] 33  UIKit                               0x0000000110451a55 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke + 270
       [ERROR] 34  UIKit                               0x000000011052a7e4 +[UIView(Internal) _performBlockDelayingTriggeringResponderEvents:] + 188
       [ERROR] 35  UIKit                               0x0000000110451463 -[_UINavigationParallaxTransition animateTransition:] + 1433
       [ERROR] 36  UIKit                               0x000000011063ebff -[UINavigationController _startCustomTransition:] + 4426
       [ERROR] 37  UIKit                               0x000000011064ec34 -[UINavigationController _startDeferredTransitionIfNeeded:] + 697
       [ERROR] 38  UIKit                               0x000000011064fdc7 -[UINavigationController __viewWillLayoutSubviews] + 58
       [ERROR] 39  UIKit                               0x0000000110846d6f -[UILayoutContainerView layoutSubviews] + 223
       [ERROR] 40  UIKit                               0x0000000128ea5251 -[UILayoutContainerViewAccessibility layoutSubviews] + 43
       [ERROR] 41  UIKit                               0x000000011052ff50 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
       [ERROR] 42  QuartzCore                          0x0000000113579cc4 -[CALayer layoutSublayers] + 146
       [ERROR] 43  QuartzCore                          0x000000011356d788 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
       [ERROR] 44  QuartzCore                          0x000000011356d606 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
       [ERROR] 45  QuartzCore                          0x00000001134fb680 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
       [ERROR] 46  QuartzCore                          0x0000000113528767 _ZN2CA11Transaction6commitEv + 475
       [ERROR] 47  UIKit                               0x0000000110464a97 _UIApplicationFlushRunLoopCATransactionIfTooLate + 206
       [ERROR] 48  UIKit                               0x0000000110c746e0 __handleEventQueue + 5672
       [ERROR] 49  CoreFoundation                      0x00000001152b4311 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
       [ERROR] 50  CoreFoundation                      0x000000011529959c __CFRunLoopDoSources0 + 556
       [ERROR] 51  CoreFoundation                      0x0000000115298a86 __CFRunLoopRun + 918
       [ERROR] 52  CoreFoundation                      0x0000000115298494 CFRunLoopRunSpecific + 420
       [ERROR] 53  GraphicsServices                    0x000000011656ea6f GSEventRunModal + 161
       [ERROR] 54  UIKit                               0x000000011046b964 UIApplicationMain + 159
       [ERROR] 55  ppBootTC                            0x000000010e6c6f44 main + 100
       [ERROR] 56  libdyld.dylib                       0x0000000117b4768d start + 1
       
  2. Hans Knöchel 2016-11-11

    Test-case:
       // -- General UI -- //
       var win = Ti.UI.createWindow({
           backgroundColor: "#fff"
       });
       
       var label = Ti.UI.createLabel({
           text: "Show window"
       });
       
       label.addEventListener("click", doClick);
        
       win.add(label); 
       
       var nav = Ti.UI.iOS.createNavigationWindow({
           window: win
       });
       
       nav.open();
       
       function doClick() {
           var win2 = Ti.UI.createWindow({
               backgroundColor: "white"
           });
           
           var btn = Ti.UI.createButton({
               width: 46, 
               height: 46, 
               top: 100, 
               backgroundImage: '/images/close3.png', 
               backgroundColor: 'red' 
           });
           
           win2.add(btn);
           
           nav.openWindow(win2);
       }
       
    The crash is reproducible when you open the window for the second time and the reason seems to be that the image cache has an invalid memory address during the second access. We had a similar issue in TIMOB-24040, but it was regarding empty background images. I need to dive into the recent changes between 5.5.x and 6.0.0 to see what happened. Thx for reporting! *EDIT*: The issue was caused by [this commit](https://github.com/appcelerator/titanium_mobile/commit/7ee97f46b21ab05434d3c588e1ae24450a6eb5f0), investigating ...
  3. Hans Knöchel 2016-11-11

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/8598 PR (6_0_X): https://github.com/appcelerator/titanium_mobile/pull/8599 The issue was that when we replaced the method to get the image, we didn't retain the resulting value as before. This PR fixes that!
  4. Chee Kiat Ng 2016-11-11

    CR and FT Passed! APPROVED!
  5. Abir Mukherjee 2016-11-11

    Verified fix using this environment: NPM Version: 2.15.9 Node Version: 4.5.0 Mac OS: 10.12.1 Appc CLI: 6.0.0-69 Appc CLI NPM: 4.2.8-9 Titanium SDK version: 6.0.0. v20161111062138 Appcelerator Studio, build: 4.8.0.201611020954 Xcode 8.1 GM Device: iPhone 7 iOS 10.0.1 Simulator: iOS 10.1 Simulator An app was installed using Han's demo code. With an earlier build, Ti SDK 6.0.0.v20161031201605, I clicked on the "Show Window" button, then clicked "Back", then clicked "Show Window" a second time. At that point, the app crashed. When I tried the same steps with the latest Ti SDK 6.0.0. v20161111062138, the app did not crash. This fix was validated on both Simulator and Device.

JSON Source