Hybrid View

    Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format.
  1. #1
    Sencha User
    Join Date
    May 2011
    Location
    Northern California
    Posts
    255
    Vote Rating
    17
    BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about

      1  

    Default [ExtJS 4.1.1] Ext.require does not call callback if provided

    [ExtJS 4.1.1] Ext.require does not call callback if provided


    If I pass a callback fn to Ext.require, it never gets called. For example, Ext.require('Sjs.apps.examples.reference.Main', function() { console.log('loaded'); });

    This problem appeared in 4.1.0 and is critical to the proper functioning of our environment. This is blocking us from upgrading from 4.0.7.

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,645
    Vote Rating
    583
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Works ok for me:

    Code:
    Ext.require('Ext.panel.Panel', function(){
        console.log('Foo');
    });
    I tried it with ext-all.js and also dynamic loading against 4.1.1, the log fires in both cases.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    May 2011
    Location
    Northern California
    Posts
    255
    Vote Rating
    17
    BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about

      1  

    Default


    Ok, well I'll have to do more digging and see if I can create an example to show the problem. In our environment, we define application classes that extend Ext.app.Application, and when an app is required on the page, Ext.require is called, passing the app class name and a callback. 100% of the time, the callback never gets called because of this line in Loader.js:
    Code:
          if (syncModeEnabled) {
               callback.call(scope); 
     ...
    syncModeEnabled is always false. The callback never gets called.

    By the way, I'm using ext-dev.js. Also, the code I am using that doesn't work in 4.1.1, works fine in 4.0.5.

  4. #4
    Sencha User
    Join Date
    May 2011
    Location
    Northern California
    Posts
    255
    Vote Rating
    17
    BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about

      1  

    Default


    Interestingly, if I call Ext.syncRequire(someClass, callback), then ALL the callbacks that never got called from previous Ext.require calls suddenly get invoked. Then I get a "field is undefined" exception on Model.js.

    It is difficult to create a standalone example outside of our environment, but I'll see what I can do. But something has definitely changed with the Loader since 4.0.5.

  5. #5
    Sencha User
    Join Date
    May 2011
    Location
    Northern California
    Posts
    255
    Vote Rating
    17
    BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about BillHubbard has a spectacular aura about

      1  

    Default


    Here's a big clue:
    When our main page loads, we wind up in a state where Ext.Loader.numPendingFiles == 4. The pending files turn out to be the scripts for the classes Ext.LoadMask, Ext.Ajax, Ext.data.Store and Ext.data.AbstractStore.

    Coincidentally, in the Ext.Loader.loadScriptFile method, there is this code:
    Code:
    if (isFileLoaded[url]) {
        return Loader; 
    }
    If I write the url to the console at this point, guess what files I see?
    Code:
    http://hom-bhubbard3/assets/scripts/deploy/ext-live/src/data/AbstractStore.js already loaded
    http://hom-bhubbard3/assets/scripts/deploy/ext-live/src/data/Store.js already loaded
    http://hom-bhubbard3/assets/scripts/deploy/ext-live/src/Ajax.js already loaded
    http://hom-bhubbard3/assets/scripts/deploy/ext-live/src/LoadMask.js already loaded
    Having that check in loadScriptFile prevents the onLoad handler from getting called. This check was not present in 4.0.5. The expectation is that the onLoad handler should always get called, even if the file is already loaded. That's not happening.

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,645
    Vote Rating
    583
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      -2  

    Default


    I still see the callback fired:

    Code:
    Ext.require('Ext.panel.Panel');
    
    Ext.onReady(function() {
        
        Ext.require('Ext.panel.Panel', function(){
            console.log('loaded');
        });
        
    });
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!