Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-2803 in a recent build.
  1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    112
    Vote Rating
    92
    fdp is just really nice fdp is just really nice fdp is just really nice fdp is just really nice

      0  

    Default Native App on iOS will not work if you require Ext.device.Device (2.0.1-rc)

    Native App on iOS will not work if you require Ext.device.Device (2.0.1-rc)


    REQUIRED INFORMATION


    Ext version tested:
    • Sencha Touch 2.0.1-rc
    • SenchaSDKTools-2.0.0-beta2


    Browser versions tested against:
    • iOS Native App (it works on iOS Simulator, Chrome, etc.)


    DOCTYPE tested against:
    • Irrelevant


    Description:
    • App hangs before Ext.application launch function
      It tooks me several hours to find this bug.
      My App work well on any browser,
      I'm able to build testing/development/production without any error
      I'm also to build native without any error but the resulting app does not work!
      The App hangs on splash screen (the scripts never executes application launch and controllers init methods)
      I was unable to debug the problem even using weinre and other debug tools.
      So I did several tries cutting code lines
      At least I find that the only line that make it hang is the require of Ext.device.Device event without using the api at all.


    Steps to reproduce the problem:
    • Build any app to native (sencha app build native command)


    The result that was expected:
    • App working


    The result that occurs instead:
    • App hangs!


    Test Case:
    Code:
    move to 2.0.1-rc path
    sencha generate app -n Test1 -p wwwTest1
    edit app.js and add 'Ext.device.Device' to requires
    sencha app build native
    make ipa for test1 app
    launch test1 app from iOS device

    HELPFUL INFORMATION


    Screenshot or Video:
    • None


    See this URL for live test case: http://


    Debugging already done:
    • 4+ hours of debug with many tools including weinre.
      It seems like that the window.device is missing in the App!


    Possible fix:
    • a new build of stbuild_template


    Additional CSS used:
    • Irrelevant


    Operating System:
    • iOS

  2. #2
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    18
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    Thank you for the report.

    Sencha Inc

    Jamie Avins

    @jamieavins

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    112
    Vote Rating
    92
    fdp is just really nice fdp is just really nice fdp is just really nice fdp is just really nice

      0  

    Default


    This bug is still here even with:
    • Sencha Touch 2.0.1
    • SenchaSDKTools-2.0.0-beta3
    Simpy adding this line of code
    Code:
    requires: ['Ext.device.Device']
    the generated app will not work on real iOS device.

    Please let me know, thanks!

  4. #4
    Sencha User
    Join Date
    Nov 2011
    Posts
    61
    Vote Rating
    3
    FrankK is on a distinguished road

      0  

    Default


    I've been having issues with phonegap when requiring this class. I opened up Ext.device.device.PhoneGap and I moved the 3 variables from the constructor function to the initialize function. This seems to add a little white space into the page load, but the app does load after without any errors. The same might work for the Sencha version of the class.

  5. #5
    Sencha User
    Join Date
    Mar 2012
    Location
    Leeuwarden, Netherlands
    Posts
    20
    Vote Rating
    0
    fokkezb is on a distinguished road

      0  

    Default


    Problem confirmed for ST 2.0.1. When you add
    Code:
    Ext.require('Ext.device.Device');
    to your app.'s and call
    Code:
    sencha app build package
    you'll get:

    Code:
    [INFO] Resolving your application dependencies (file:////Applications/MAMP/htdocs/Device/index.html)[ERROR] ReferenceError: Can't find variable: device
    Stack trace:
       file:////Applications/MAMP/htdocs/Device/sdk/src/device/device/PhoneGap.js?_dc=1335720151826 : 8 : Ext.device.device.PhoneGap#constructor
       file:////Applications/MAMP/htdocs/Device/sdk/sencha-touch.js : 4951 : Ext.device.device.PhoneGap
        : 1 : Ext.ClassManager.instantiate0
       file:////Applications/MAMP/htdocs/Device/sdk/sencha-touch.js : 6459 : Anonymous
    ...
    I've tracked it down and the problem is in the WebView detection in
    Code:
    Ext.env.Browser
    . It only checks for window.PhoneGap, but should also check if the deviceType is a phone. Otherwise,
    Code:
    Ext.device.Device
    will construct the PhoneGap subclass during packaging and give the above error.

  6. #6
    Sencha User
    Join Date
    Mar 2012
    Location
    Leeuwarden, Netherlands
    Posts
    20
    Vote Rating
    0
    fokkezb is on a distinguished road

      0  

    Default More info on why the native app hangs

    More info on why the native app hangs


    If you add the following script in your index.html

    Code:
    window.onerror = function(error) {  alert(error);
    };
    You'll see the reason of the blank screen:

    Code:
    ReferenceError: Can't find variable: device
    It seems like it's the same error I described that occurs during packaging. The Ext.device.Device.Phonegap class tries to read PhoneGaps device.* before it fires the deviceready event.

  7. #7
    Sencha User
    Join Date
    Mar 2011
    Posts
    112
    Vote Rating
    92
    fdp is just really nice fdp is just really nice fdp is just really nice fdp is just really nice

      0  

    Default


    Any fix available around?

  8. #8
    Sencha User
    Join Date
    Mar 2012
    Location
    Leeuwarden, Netherlands
    Posts
    20
    Vote Rating
    0
    fokkezb is on a distinguished road

      0  

    Default


    Sencha's launch/initialize methods wait for PhoneGap's "deviceready" event, but the Ext.device.Device classes are constructed before, so they are useless.

    Don't use (and require) Ext.device.Device for now and just access PhoneGap's device.* parameters directly in your classes, but only in methods - like initialize - that are called AFTER the application launch of course.

    Make sure you test for device.* so your application also works on your desktop while developing:

    Code:
    if (typeof device !== 'undefined')
    {
    	var myDevice = {
    		name: device.name,
    		uuid: device.uuid,
    		platform: device.platformName || Ext.os.name
    	});
    } else {
    	var myDevice: {
        		name: 'not available',
        		uuid: 'anonymous',
        		platform: Ext.os.name
        	}
    }

  9. #9
    Sencha User
    Join Date
    Mar 2012
    Location
    Leeuwarden, Netherlands
    Posts
    20
    Vote Rating
    0
    fokkezb is on a distinguished road

      0  

    Default Possible fix

    Possible fix


    Code:
    Ext.define('Ext.device.device.PhoneGap', {
        extend: 'Ext.device.device.Abstract',
    
    
        constructor: function() {
            Ext.onReady(function() {
                this.name = device.name;
                this.uuid = device.uuid;
                this.platform = device.platformName || Ext.os.name;
            }, this);
        }
    });

  10. #10
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    Fixed for the next release. Here is how I fixed it:

    Code:
    /**
     * @private
     */
    Ext.define('Ext.device.device.PhoneGap', {
        extend: 'Ext.device.device.Abstract',
    
        constructor: function() {
            // We can't get the device details until the device is ready, so lets wait.
            if (Ext.Viewport.isReady) {
                this.onReady();
            } else {
                Ext.Viewport.on('ready', this.onReady, this, {single: true});
            }
        },
    
        onReady: function() {
            this.name = device.name;
            this.uuid = device.uuid;
            this.platform = device.platformName || Ext.os.name;
        }
    });
    Thanks!
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.