tidev/titanium-sdk

iOS: calling navTintColor twice will crash the app

m1ga opened this issue · 1 comments

m1ga commented

I have searched and made sure there are no existing issues for the issue I am filing

  • I have searched the existing issues

Description

Setting a navTintColor twice will crash the app. The example app will show a simple tabgroup app and the timeout simulates a server request or the cached version (no timeout = crash).

A higher timeout value (waiting for the server response) works fine. But when the data is cached (timeout: 0) it will crash.

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib               	    0x7ff80002dacb objc_msgSend + 11
1   TitaniumKit                   	       0x10adedc4a __35-[TiUIWindowProxy setNavTintColor:]_block_invoke + 189
2   libdispatch.dylib             	    0x7ff80013be40 _dispatch_call_block_and_release + 12
3   libdispatch.dylib             	    0x7ff80013d0d9 _dispatch_client_callout + 8
4   libdispatch.dylib             	    0x7ff80014cb86 _dispatch_main_queue_drain + 1330
5   libdispatch.dylib             	    0x7ff80014c646 _dispatch_main_queue_callback_4CF + 31
6   CoreFoundation                	    0x7ff8003b26cc __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
7   CoreFoundation                	    0x7ff8003acfbe __CFRunLoopRun + 2429
8   CoreFoundation                	    0x7ff8003ac264 CFRunLoopRunSpecific + 560
9   GraphicsServices              	    0x7ff809b4024e GSEventRunModal + 139
10  UIKitCore                     	       0x119e3b7bf -[UIApplication _run] + 994
11  UIKitCore                     	       0x119e405de UIApplicationMain + 123
12  test_ios                      	       0x10849ec3b main + 1019 (main.m:77)
13  dyld_sim                      	       0x108a39384 start_sim + 10
14  dyld                          	       0x112b0541f start + 1903

Expected Behavior

not crash the app

Actual behavior

crashing the app.

Reproducible sample

var win1 = Ti.UI.createWindow({});
win1.add(Ti.UI.createLabel({text: 'Click', touchEnabled: false}));

var win2 = Ti.UI.createWindow({});

var tab1 = Ti.UI.createTab({ window: win1, title: 'win1'}),
tab2 = Ti.UI.createTab({ window: win2, title: 'win2'}),
tabGroup = Ti.UI.createTabGroup({ tabs: [tab1, tab2]});

tabGroup.open();


win1.addEventListener("click", function(){
    var win3 = Ti.UI.createWindow({ navTintColor: "red" });
    tabGroup.activeTab.openWindow(win3);

    setTimeout(function(){
        win3.applyProperties({
            navTintColor: "yellow"
        })
    },0)         // <----- 0 = crash, 1000 = no crash
})

Steps to reproduce

  • open the app
  • click the first window
  • crash

  • change the timeout to a higher number
  • open the app
  • click the first window
  • no crash

Platform

iOS

SDK version you are using

12.3.0

Alloy version you are using

No response

m1ga commented

__block TiColor *newColor = [TiUtils colorValue:color];

should there be a return [newColor autorelease]; ?