Titanium JIRA Archive
Alloy (ALOY)

[ALOY-912] Alloy 1.3.0 ignores formfactor in headerView - leads in crash

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-01-07T20:39:59.000+0000
Affected Version/sn/a
Fix Version/sAlloy 1.3.1
ComponentsXML
Labelsalloy, qe-testadded
ReporterJick Steen
AssigneeTony Lukasavage
Created2013-11-19T07:58:38.000+0000
Updated2014-07-31T18:24:45.000+0000

Description

Hi, just upgraded to latest Alloy master version and noticed a crash when a headerView is only used for instance on a tablet:
$.index.open();
<Alloy>
    <Window class="container">    
        <TableView>
            <HeaderView formFactor="tablet">
                <View>
                    <Label>Text</Label>
                </View>
            </HeaderView>
        </TableView>
    </Window>
</Alloy>
Tested on Android 4.1.3 with Samsung Galaxy S2. Problem is it only creates the HeaderView on tablets but always wants to set the headerView property even on handhelds where the headerView does not exist.

Environment

- OSX 10.8.5 - iOS Simulator 7.0 - Xcode 5.0.1 - Latest Titanium SDK: 3.2.0.v20131108155642 - Latest Titanium CLI Master 3.2.0 - Latest Alloy Master 1.3.0 Link to Q&A: [http://developer.appcelerator.com/question/159540/alloy-130-ignores-formfactor-in-headerview---leads-in-crash]

Attachments

FileDateSize
logs.txt2013-12-29T11:05:40.000+000017331

Comments

  1. Jick Steen 2013-11-25

    FYI: As I can release my app only having this fixed, I had a look to fix it. It seems to work for me but I guess it is not really a proper fix. What I basically did is assigning ProxyProperties that have a condition after creating the TableView instance. Because it looks like assigning
    Ti.UI.createTableView({headerView: undefined})
    or
    {Ti.UI.createTableView({headerView: null})
    both leads in a crash on Android.
       diff --git a/Alloy/commands/compile/parsers/Ti.UI.TableView.js b/Alloy/commands/compile/parsers/Ti.UI.TableView.js
       index a279b72..e247035 100644
       --- a/Alloy/commands/compile/parsers/Ti.UI.TableView.js
       +++ b/Alloy/commands/compile/parsers/Ti.UI.TableView.js
       @@ -31,6 +31,7 @@ function parse(node, state, args) {
                       isDataBound = args[CONST.BIND_COLLECTION] ? true : false,
                       extras = [],
                       proxyProperties = {},
       +               conditionedProxyProperties = {},
                       localModel, arrayName, controllerSymbol;
        
               // iterate through all children of the TableView
       @@ -77,7 +78,11 @@ function parse(node, state, args) {
                               code += CU.generateNodeExtended(child, state, {
                                       parent: {},
                                       post: function(node, state, args) {
       -                                       proxyProperties[U.proxyPropertyNameFromFullname(fullname)] = state.parent.symbol;
       +                                       if (state.parent.condition) {
       +                                               conditionedProxyProperties[U.proxyPropertyNameFromFullname(fullname)] = {condition: state.parent.condition, symbol: state.parent.symbol};
       +                                       } else {
       +                                               proxyProperties[U.proxyPropertyNameFromFullname(fullname)] = state.parent.symbol;
       +                                       }
                                       }
                               });
        
       @@ -162,6 +167,12 @@ function parse(node, state, args) {
               var tableState = require('./default').parse(node, state);
               code += tableState.code;
        
       +       if (conditionedProxyProperties) {
       +               _.each(conditionedProxyProperties, function (v, k) {
       +                       code += 'if (' + v.condition + ') {' + tableState.parent.symbol + "." + k + '= ' + v.symbol + "; }"
       +               });
       +       }
       +
               // finally, fill in any model-view binding code, if present
               if (isDataBound) {
                       localModel = localModel || CU.generateUniqueId();
       diff --git a/Alloy/commands/compile/parsers/_ProxyProperty.js b/Alloy/commands/compile/parsers/_ProxyProperty.js
       index 192b4e0..23f805e 100644
       --- a/Alloy/commands/compile/parsers/_ProxyProperty.js
       +++ b/Alloy/commands/compile/parsers/_ProxyProperty.js
       @@ -50,7 +50,8 @@ function parse(node, state, args) {
        
               return {
                       parent: {
       -                       symbol: proxy
       +                       symbol: proxy,
       +                       condition: state.condition
                       },
                       isProxyProperty: true,
                       propertyName: U.lcfirst(args.fullname.match(/\.([^\.]+)$/)[1] || '')
       
  2. Eric Wieber 2013-12-03

    Hi, After testing the code on several tablets and Android phones, from 2.2 to 4.2, I was not able to reproduce this issue. The "Test" text properly showed up on tablets and not on phones. I did not witness a crash with Ti SDK 3.1.3 or 3.2. Can you please try out the latest nightly build of the TISDK and let us know an update if you continue to get this crashed. Thanks,
  3. Jick Steen 2013-12-17

    Strange, I still can reproduce the issue: http://pastebin.com/0REU3sBg alloy --version = 1.3.0 (Just updated to latest master using
    sudo npm install -g git://github.com/appcelerator/alloy.git
    ) titanium --version = 3.3.0 (Just updated to latest master) Host OS: Mac OS X OS Version: 10.8.5 OS Arch: x86 JRE Version: 1.6.0_65 Titanium Studio Version: 3.2.1.201312142230 Latest Titanium SDK: 3.2.0.v20131216191854 Android SDK Version: 4.4 Android NDK Version: Unknown/Uninstalled Titanium CLI Enabled: true Tested on Samsung Galaxy S2 with Android 4.1.2 Generated controller code looks like this: http://pastebin.com/LkMzM6vq Notice line 28 where headerView is asigned but only generated for tablets in line 15.
  4. Tony Lukasavage 2014-01-07

    commit: https://github.com/appcelerator/alloy/pull/296 test app: https://github.com/appcelerator/alloy/tree/master/test/apps/testing/ALOY-912 Merged in master and 1_3_X Functional testing can be done on the app in the comments, or on the test app listed here. Both simply need to be run on android and not produce a runtime error. Before this fix, a runtime error would occur on android.
  5. Federico Casali 2014-01-07

    Verified fixed. TiSDK 3.2.1.v20140106195644 Appcelerator Studio 3.2.1.201401061716 Alloy 1.3.1-beta2 Android Google Nexus Galaxy 4.3 iPhone 5 iOS7 Closing
  6. Federico Casali 2014-02-05

    Verified as fixed. TiSDK 3.2.1.v20140203174850 Alloy 1.3.1-cr2 CLI 3.2.1-beta3 Appcelerator Studio 3.2.1.201402041206 iPhone 5 iOS 7 Android Google Nexus Galaxy 4.3 Closing

JSON Source