Uploaded image for project: 'Titanium Mobile'
  1. Titanium Mobile
  2. TIMOB-11294

Android: console: log functions fail in commonjs require

    Details

      Description

      [ERROR][TiJSError( 744)] (main) [0,1111] - Message: Uncaught ReferenceError: console is not defined
      [ERROR][TiJSError( 744)] (main) [0,1111] - Source:console.debug("drawAnnotation");

      Another Log:

      [ERROR][TiExceptionHandler(  656)] (main) [618,1470] ----- Titanium Javascript Runtime Error -----
      [ERROR][TiExceptionHandler(  656)] (main) [1,1471] - In require.js:1,1
      [ERROR][TiExceptionHandler(  656)] (main) [0,1471] - Message: Uncaught ReferenceError: console is not defined
      [ERROR][TiExceptionHandler(  656)] (main) [0,1471] - Source: console.log('require');
      [ERROR][V8Exception(  656)] Exception occurred at require.js:1: Uncaught ReferenceError: console is not defined
      

      seems like console works fine on IOS but throws errors on Android.

      Any console object calls in a commonjs module will fail on android, they work from app.js though.

      This is not a regression.

      Docs: http://docs.appcelerator.com/titanium/2.1/index.html#!/api/Global.console

      Steps to Reproduce:

      1. Run code:

      require.js

      console.log('console.log');
      console.debug('console.debug');
      console.warn('console.warn');
      console.error('console.error');
      console.info('console.info');
      

      app.js

      require('require');
      

      Actual Result:

      Runtime error.

      Expected Result:

      Console message logged.

        Issue Links

          Activity

          Hide
          tlukasavage Tony Lukasavage added a comment -

          This was originally logged as a TC ticket, then moved to ALOY. As "drawAnnotation" is used nowhere in the Alloy code, I'm assuming this is either related to the test code used to generate this error, or an underlying Android issue. I"ll add myself as a watcher in case this does in fact turn out to be Alloy-specific.

          Aaron, can you provide the test code necessary to reproduce this error?

          Show
          tlukasavage Tony Lukasavage added a comment - This was originally logged as a TC ticket, then moved to ALOY. As "drawAnnotation" is used nowhere in the Alloy code, I'm assuming this is either related to the test code used to generate this error, or an underlying Android issue. I"ll add myself as a watcher in case this does in fact turn out to be Alloy-specific. Aaron, can you provide the test code necessary to reproduce this error?
          Hide
          dhyde Dustin Hyde added a comment -

          Updating ticket.

          Show
          dhyde Dustin Hyde added a comment - Updating ticket.
          Hide
          dhyde Dustin Hyde added a comment -

          It's a scope problem.

          Show
          dhyde Dustin Hyde added a comment - It's a scope problem.
          Show
          ayeung Allen Yeung added a comment - PR: https://github.com/appcelerator/titanium_mobile/pull/3360
          Hide
          dhyde Dustin Hyde added a comment -

          Also fails in win.url files.

          app.js

          Ti.API.info('win.url.open()');
           
          var win = Ti.UI.createWindow({
          	url : 'module.js'
          });
           
          win.open();

          module.js

          console.log('console LOG');
          console.log(['console LOG', 'ARG1', 'ARG2']);
           
          console.debug('console DEBUG');
          console.debug(['console DEBUG', 'ARG1', 'ARG2']);
           
          console.info('console INFO');
          console.info(['console INFO', 'ARG1', 'ARG2']);
           
          console.warn('console WARN');
          console.warn(['console WARN', 'ARG1', 'ARG2']);
           
          console.error('console ERROR');
          console.error(['console ERROR', 'ARG1', 'ARG2']);

          Console Output:

          [ERROR][TiJSError(  649)] (main) [558,1734] ----- Titanium Javascript Runtime Error -----
          [ERROR][TiJSError(  649)] (main) [0,1734] - In module.js:5,2
          [ERROR][TiJSError(  649)] (main) [0,1734] - Message: Uncaught ReferenceError: console is not defined
          [ERROR][TiJSError(  649)] (main) [1,1735] - Source: 	console.log('console LOG');
          [ERROR][V8Exception(  649)] Exception occurred at module.js:5: Uncaught ReferenceError: console is not defined

          Show
          dhyde Dustin Hyde added a comment - Also fails in win.url files. app.js Ti.API.info('win.url.open()');   var win = Ti.UI.createWindow({ url : 'module.js' });   win.open(); module.js console.log('console LOG'); console.log(['console LOG', 'ARG1', 'ARG2']); console.debug('console DEBUG'); console.debug(['console DEBUG', 'ARG1', 'ARG2']); console.info('console INFO'); console.info(['console INFO', 'ARG1', 'ARG2']); console.warn('console WARN'); console.warn(['console WARN', 'ARG1', 'ARG2']);   console.error('console ERROR'); console.error(['console ERROR', 'ARG1', 'ARG2']); Console Output: [ERROR][TiJSError( 649)] (main) [558,1734] ----- Titanium Javascript Runtime Error ----- [ERROR][TiJSError( 649)] (main) [0,1734] - In module.js:5,2 [ERROR][TiJSError( 649)] (main) [0,1734] - Message: Uncaught ReferenceError: console is not defined [ERROR][TiJSError( 649)] (main) [1,1735] - Source: console.log('console LOG'); [ERROR][V8Exception( 649)] Exception occurred at module.js:5: Uncaught ReferenceError: console is not defined
          Hide
          pwang Ping Wang added a comment -
          Show
          pwang Ping Wang added a comment - PR for fixing window URL file: https://github.com/appcelerator/titanium_mobile/pull/3371
          Show
          mstepanov Max Stepanov added a comment - 3_0_X PR https://github.com/appcelerator/titanium_mobile/pull/3465
          Hide
          tsmolich Tamila Smolich added a comment -

          Closing as fixed. Tested on:
          Titanium Studio, build: 3.0.0.201211301903
          Titanium SDK, builds: 3.0.0.v20121130200208; 3.1.0.v20121203181001
          Devices: Samsung Galaxy S III (4.0.4)

          Show
          tsmolich Tamila Smolich added a comment - Closing as fixed. Tested on: Titanium Studio, build: 3.0.0.201211301903 Titanium SDK, builds: 3.0.0.v20121130200208; 3.1.0.v20121203181001 Devices: Samsung Galaxy S III (4.0.4)

            People

            • Assignee:
              ayeung Allen Yeung
              Reporter:
              aaron@clearlyinnovative.com Aaron K. Saunders
              Tester:
              Lokesh Choudhary
            • Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development

                  Poker Sessions

                  This issue is currently not assigned to any Poker Session.