Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha Premium Member robert_k's Avatar
    Join Date
    Jun 2012
    Posts
    35
    Vote Rating
    1
    robert_k is on a distinguished road

      0  

    Exclamation Adding a tap listener to a container's element causes a segfault (Chrome & Safari)

    Adding a tap listener to a container's element causes a segfault (Chrome & Safari)


    I've tested the following on OSX 10.6.8 with both Chrome 25.0.1364.172 and Safari 5.1.7 (6534.57.2). The affected build is Sencha Touch 2.1.1. The fastest way to confirm this bug is to go to the Ext.Container documentation and replace the code sample with the following block of code.

    Code:
    var aboutPanel = Ext.create('Ext.Panel', {
      xtype: 'container',
      html: "<p>Just click me to crash the browser.</p>",
      listeners: {
        initialize: function (me, opts) {
          me.element.on('tap', function (e) {
            // this.fireAction('tap', [this, e], 'doTap');
            this.fireEvent('tap', this, e);
          });
        }
      }
    });
    
    //this is the Panel we'll be adding to
    var mainPanel = Ext.create('Ext.Panel', {
        fullscreen: true,
    
        layout: 'hbox',
        defaults: {
            flex: 1
        },
    
        items: {
            html: 'First Panel',
            style: 'background-color: #5E99CC;'
        }
    });
    
    //now we add the first panel inside the second
    mainPanel.add(aboutPanel);
    For me this will throw a RangeError immediately in either browser. I'm trying to get the Container to fire the "tap" event so that I can listen for it in the controller. I think that Ext.Panel doesn't have the same issue.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,522
    Vote Rating
    814
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    That's not the preferred way to add an element listener:

    Code:
    var aboutPanel = Ext.create('Ext.Panel', {
        xtype     : 'container',
        html      : '<p>Just click me to crash the browser.</p>',
        listeners : {
            element : 'element',
            tap     : function(e) {
                this.fireEvent('tap', this, e);
            }
        }
    });
    
    //this is the Panel we'll be adding to
    var mainPanel = Ext.create('Ext.Panel', {
        fullscreen : true,
    
        layout   : 'hbox',
        defaults : {
            flex  : 1
        },
    
        items : {
            html  : 'First Panel',
            style : 'background-color: #5E99CC;'
        }
    });
    
    //now we add the first panel inside the second
    mainPanel.add(aboutPanel);
    With this I don't get a crash.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha Premium Member robert_k's Avatar
    Join Date
    Jun 2012
    Posts
    35
    Vote Rating
    1
    robert_k is on a distinguished road

      0  

    Default


    It's been rather obnoxious to get this to work. Originally I used code like yours but the event would never fire whether I put it into the controller or the container. So I resorted to the initializer to try and attach the event to the DOM element, which worked but tended to throw a lot of errors. This is basically the same code in 2 not-so-different areas, so why does it effectively segfault when the listener is added during component initialization and not with the "normal" listener? I can't help but think that the same kind of listener code should work no matter how its attached—but I could be wrong.

    So now, going back to the original code I tried and adding

    Code:
    console.dir(arguments);
    this.fireEvent('tap', this, e);
    somehow allows the event to fire, when just a console.dir didn't output anything before.

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,522
    Vote Rating
    814
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I use the same code I posted in my apps and am able to listen to them in the controller with no problems.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.