org.mozilla.javascript.EcmaError: TypeError: Cannot read property "x" from null (file:///android_asset/Resources/app.js#9)

Appcelerator JIRA | Jon Alter | 5 years ago
  1. 0

    globalPoint is null for touchstart events for windows or views Step 1: run the code below Step 2: tap the window Step 3: look at the error in the console {code:title="app.js"} var win = Ti.UI.createWindow({ backgroundColor: 'blue' }); win.addEventListener('touchstart', function(e){ Ti.API.info("Touch Started for view: " + e.source); Ti.API.info("View Center: " + e.source.center.x + "," + e.source.center.y); Ti.API.info("e.globalPoint: " + e.globalPoint); Ti.API.info("Start Touch: " + e.globalPoint.x + "," + e.globalPoint.y); }); win.open(); {code} {code:title="console"} W/InputManagerService( 84): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@41a3c340 D/dalvikvm( 84): GC_CONCURRENT freed 1895K, 51% free 13619K/27655K, paused 7ms+11ms I/TiAPI ( 602): (kroll$1: app://app.js) [27143,93021] Touch Started for view: [Ti.UI.Window] I/TiAPI ( 602): (kroll$1: app://app.js) [14,93035] View Center: 640,363.5 I/TiAPI ( 602): (kroll$1: app://app.js) [4,93039] e.globalPoint: null E/KrollCallback( 602): (kroll$1: app://app.js) [3,93042] ECMA Error evaluating source, invocation: [callMethod UI.Window.UI.Window:event:touchstart null], message: TypeError: Cannot read property "x" from null (file:///android_asset/Resources/app.js#9) E/KrollCallback( 602): org.mozilla.javascript.EcmaError: TypeError: Cannot read property "x" from null (file:///android_asset/Resources/app.js#9) E/KrollCallback( 602): at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3784) E/KrollCallback( 602): at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3762) E/KrollCallback( 602): at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3790) E/KrollCallback( 602): at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3809) E/KrollCallback( 602): at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3822) E/KrollCallback( 602): at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1507) E/KrollCallback( 602): at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1398) E/KrollCallback( 602): at script(file:///android_asset/Resources/app.js:9) E/KrollCallback( 602): at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854) E/KrollCallback( 602): at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164) E/KrollCallback( 602): at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426) E/KrollCallback( 602): at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177) E/KrollCallback( 602): at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162) E/KrollCallback( 602): at org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:139) E/KrollCallback( 602): at org.appcelerator.titanium.kroll.KrollCallback$1.run(KrollCallback.java:164) E/KrollCallback( 602): at android.os.Handler.handleCallback(Handler.java:587) E/KrollCallback( 602): at android.os.Handler.dispatchMessage(Handler.java:92) E/KrollCallback( 602): at android.os.Looper.loop(Looper.java:126) E/KrollCallback( 602): at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86) E/TiJSError( 602): (kroll$1: app://app.js) [16,93058] ----- Titanium Javascript Runtime Error ----- E/TiJSError( 602): (kroll$1: app://app.js) [3,93061] - In file:///android_asset/Resources/app.js:9,0 E/TiJSError( 602): (kroll$1: app://app.js) [1,93062] - Message: TypeError: Cannot read property "x" from null (file:///android_asset/Resources/app.js#9) E/TiJSError( 602): (kroll$1: app://app.js) [3,93065] - Source: null D/SntpClient( 84): request time failed: java.net.SocketException: Address family not supported by protocol D/SntpClient( 84): request time failed: java.net.SocketException: Address family not supported by protocol {code} h3. Associated Helpdesk Ticket http://appc.me/c/APP-115761

    Appcelerator JIRA | 5 years ago | Jon Alter
    org.mozilla.javascript.EcmaError: TypeError: Cannot read property "x" from null (file:///android_asset/Resources/app.js#9)
  2. 0

    As per [this comment|http://jira.appcelerator.org/browse/TIMOB-839?focusedCommentId=124175&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-124175] made around Ti 1.5.0, the x and y properties of a view being animated are not exposed to events. You can test this by running the KS scripts {{basic_animation.js}} (self-contained version below, fails if the circle.addEventListener is uncommented) and {{animation_points.js}} that both result in a fatal exceptions. {code:javascript|title=app.js} var win = Ti.UI.createWindow({ backgroundColor:'#fff', layout:'vertical', exitOnClose:true }); var circle = Titanium.UI.createView({ height:100, width:100, borderRadius:50, backgroundColor:'#336699', top:10 }); win.add(circle); var label = Titanium.UI.createLabel({ text:'Click circle repeatedly to animate or drag the circle', bottom:100, color:'#555', font:{fontSize:12,fontFamily:'Helvetica Neue'}, textAlign:'center', height:'auto', width:'auto' }); win.add(label); // UNCOMMENT THIS TO SEE EXCEPTION // circle.addEventListener('touchmove', function(e) // { // Ti.API.debug('Our event tells us the center is ' + e.x + ', ' + e.y ); // var newX = e.x + circle.animatedCenter.x - circle.width/2; // var newY = e.y + circle.animatedCenter.y - circle.height/2; // circle.animate({center:{x:newX,y:newY}, duration:1}); // }); var mode = 0; circle.addEventListener('click', function() { switch(mode) { case 0: firstAnimation(); mode++; break; case 1: secondAnimation(); mode++; break; case 2: thirdAnimation(); mode++; break; case 3: fourthAnimation(); mode=0; break; } }); // // ANIMATION FUNCTIONS // // opacity - use inline animation object function firstAnimation() { var t = Ti.UI.create2DMatrix(); t.a = 1; t.b = 2; t.c = 3; t.d = 4; // pass inline animation objects and get callback when done circle.animate({opacity:0,transform:t,duration:500}, function() { var t = Ti.UI.create2DMatrix(); circle.animate({opacity:1,transform:t,duration:500}); }); } // background color - use animation object function secondAnimation() { var a = Titanium.UI.createAnimation(); a.backgroundColor = '#ff0000'; a.duration = 1000; var b = Titanium.UI.createAnimation(); b.backgroundColor = '#336699'; b.duration = 1000; circle.animate(a); a.addEventListener('start', function() { Ti.API.info('IN START'); label.text = 'Animation started'; }); a.addEventListener('complete', function() { Ti.API.info('IN COMPLETE'); label.text = 'Animation completed'; circle.animate(b); setTimeout(function() { label.text = 'Click circle repeatedly to animate or drag window'; },2000); }); } function thirdAnimation() { circle.animate({top:200,right:30,duration:500}, function() { circle.animate({top:0,left:0, duration:500}); }); } function fourthAnimation() { circle.animate({center:{x:100,y:100},curve:Ti.UI.ANIMATION_CURVE_EASE_IN_OUT,duration:1000}, function() { circle.animate({center:{x:0,y:200},duration:1000}, function() { circle.animate({center:{x:300,y:300},duration:1000},function() { circle.animate({center:{x:150,y:60, duration:1000}}); }); }); }); } {code} h3. Results {code} 615 KrollContext D (kroll$5: app://examples/basic_animation.js) [2085,13745] Running evaluated script: app://examples/basic _animation.js 99 ActivityManager I Displayed activity com.appcelerator.titanium/org.appcelerator.titanium.TiActivity: 557 ms (total 557 ms) 615 KrollCallback E (kroll$5: app://examples/basic_animation.js) [258,17795] ECMA Error evaluating source, invocation: [call Method UI.View.UI.View:event:touchmove null], message: TypeError: Cannot read property "x" from undefine d (app://examples/basic_animation.js#28) 615 KrollCallback E org.mozilla.javascript.EcmaError: TypeError: Cannot read property "x" from undefined (app://examples/bas ic_animation.js#28) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3784) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3762) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3790) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3809) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3822) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1507) 615 KrollCallback E at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1398) 615 KrollCallback E at script(app://examples/basic_animation.js:28) 615 KrollCallback E at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854) 615 KrollCallback E at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164) 615 KrollCallback E at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177) 615 KrollCallback E at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162) 615 KrollCallback E at org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:139) 615 KrollCallback E at org.appcelerator.titanium.kroll.KrollCallback$1.run(KrollCallback.java:164) 615 KrollCallback E at android.os.Handler.handleCallback(Handler.java:587) 615 KrollCallback E at android.os.Handler.dispatchMessage(Handler.java:92) 615 KrollCallback E at android.os.Looper.loop(Looper.java:123) 615 KrollCallback E at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86) 615 TiJSError E (kroll$5: app://examples/basic_animation.js) [8,17803] ----- Titanium Javascript Runtime Error ----- 615 TiJSError E (kroll$5: app://examples/basic_animation.js) [3,17806] - In app://examples/basic_animation.js:28,0 615 TiJSError E (kroll$5: app://examples/basic_animation.js) [1,17807] - Message: TypeError: Cannot read property "x" fr om undefined (app://examples/basic_animation.js#28) 615 TiJSError E (kroll$5: app://examples/basic_animation.js) [2,17809] - Source: null {code}

    Appcelerator JIRA | 5 years ago | Paul Dowsett
    org.mozilla.javascript.EcmaError: TypeError: Cannot read property "x" from undefined (app://examples/bas ic_animation.js#28)
  3. 0

    As per [this comment|http://jira.appcelerator.org/browse/TIMOB-839?focusedCommentId=124175&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-124175] made around Ti 1.5.0, the x and y properties of a view being animated are not exposed to events. You can test this by running the KS scripts {{basic_animation.js}} (self-contained version below, fails if the circle.addEventListener is uncommented) and {{animation_points.js}} that both result in a fatal exceptions. {code:javascript|title=app.js} var win = Ti.UI.createWindow({ backgroundColor:'#fff', layout:'vertical', exitOnClose:true }); var circle = Titanium.UI.createView({ height:100, width:100, borderRadius:50, backgroundColor:'#336699', top:10 }); win.add(circle); var label = Titanium.UI.createLabel({ text:'Click circle repeatedly to animate or drag the circle', bottom:100, color:'#555', font:{fontSize:12,fontFamily:'Helvetica Neue'}, textAlign:'center', height:'auto', width:'auto' }); win.add(label); // UNCOMMENT THIS TO SEE EXCEPTION // circle.addEventListener('touchmove', function(e) // { // Ti.API.debug('Our event tells us the center is ' + e.x + ', ' + e.y ); // var newX = e.x + circle.animatedCenter.x - circle.width/2; // var newY = e.y + circle.animatedCenter.y - circle.height/2; // circle.animate({center:{x:newX,y:newY}, duration:1}); // }); var mode = 0; circle.addEventListener('click', function() { switch(mode) { case 0: firstAnimation(); mode++; break; case 1: secondAnimation(); mode++; break; case 2: thirdAnimation(); mode++; break; case 3: fourthAnimation(); mode=0; break; } }); // // ANIMATION FUNCTIONS // // opacity - use inline animation object function firstAnimation() { var t = Ti.UI.create2DMatrix(); t.a = 1; t.b = 2; t.c = 3; t.d = 4; // pass inline animation objects and get callback when done circle.animate({opacity:0,transform:t,duration:500}, function() { var t = Ti.UI.create2DMatrix(); circle.animate({opacity:1,transform:t,duration:500}); }); } // background color - use animation object function secondAnimation() { var a = Titanium.UI.createAnimation(); a.backgroundColor = '#ff0000'; a.duration = 1000; var b = Titanium.UI.createAnimation(); b.backgroundColor = '#336699'; b.duration = 1000; circle.animate(a); a.addEventListener('start', function() { Ti.API.info('IN START'); label.text = 'Animation started'; }); a.addEventListener('complete', function() { Ti.API.info('IN COMPLETE'); label.text = 'Animation completed'; circle.animate(b); setTimeout(function() { label.text = 'Click circle repeatedly to animate or drag window'; },2000); }); } function thirdAnimation() { circle.animate({top:200,right:30,duration:500}, function() { circle.animate({top:0,left:0, duration:500}); }); } function fourthAnimation() { circle.animate({center:{x:100,y:100},curve:Ti.UI.ANIMATION_CURVE_EASE_IN_OUT,duration:1000}, function() { circle.animate({center:{x:0,y:200},duration:1000}, function() { circle.animate({center:{x:300,y:300},duration:1000},function() { circle.animate({center:{x:150,y:60, duration:1000}}); }); }); }); } {code} h3. Results {code} 615 KrollContext D (kroll$5: app://examples/basic_animation.js) [2085,13745] Running evaluated script: app://examples/basic _animation.js 99 ActivityManager I Displayed activity com.appcelerator.titanium/org.appcelerator.titanium.TiActivity: 557 ms (total 557 ms) 615 KrollCallback E (kroll$5: app://examples/basic_animation.js) [258,17795] ECMA Error evaluating source, invocation: [call Method UI.View.UI.View:event:touchmove null], message: TypeError: Cannot read property "x" from undefine d (app://examples/basic_animation.js#28) 615 KrollCallback E org.mozilla.javascript.EcmaError: TypeError: Cannot read property "x" from undefined (app://examples/bas ic_animation.js#28) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3784) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3762) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3790) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3809) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3822) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1507) 615 KrollCallback E at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1398) 615 KrollCallback E at script(app://examples/basic_animation.js:28) 615 KrollCallback E at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854) 615 KrollCallback E at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164) 615 KrollCallback E at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426) 615 KrollCallback E at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177) 615 KrollCallback E at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162) 615 KrollCallback E at org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:139) 615 KrollCallback E at org.appcelerator.titanium.kroll.KrollCallback$1.run(KrollCallback.java:164) 615 KrollCallback E at android.os.Handler.handleCallback(Handler.java:587) 615 KrollCallback E at android.os.Handler.dispatchMessage(Handler.java:92) 615 KrollCallback E at android.os.Looper.loop(Looper.java:123) 615 KrollCallback E at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86) 615 TiJSError E (kroll$5: app://examples/basic_animation.js) [8,17803] ----- Titanium Javascript Runtime Error ----- 615 TiJSError E (kroll$5: app://examples/basic_animation.js) [3,17806] - In app://examples/basic_animation.js:28,0 615 TiJSError E (kroll$5: app://examples/basic_animation.js) [1,17807] - Message: TypeError: Cannot read property "x" fr om undefined (app://examples/basic_animation.js#28) 615 TiJSError E (kroll$5: app://examples/basic_animation.js) [2,17809] - Source: null {code}

    Appcelerator JIRA | 5 years ago | Paul Dowsett
    org.mozilla.javascript.EcmaError: TypeError: Cannot read property "x" from undefined (app://examples/bas ic_animation.js#28)
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    --define throws error if value is `undefined`

    GitHub | 2 years ago | dantman
    org.mozilla.javascript.EcmaError: TypeError: Impossible de lire la propriété "undeclared" de undefined (scope.js#304)
  6. 0

    Empty @returns tag crashes jsdoc

    GitHub | 3 years ago | mamacdon
    org.mozilla.javascript.EcmaError: TypeError: Cannot read property "type" from undefined (file:/C:/tools/jsdoc/jsdoc3-toolkit/lib/jsdoc/util/templateHelper.js#575)

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.mozilla.javascript.EcmaError

      TypeError: Cannot read property "x" from null (file:///android_asset/Resources/app.js#9)

      at org.mozilla.javascript.ScriptRuntime.constructError()
    2. Rhino
      Interpreter.interpretLoop
      1. org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3784)
      2. org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3762)
      3. org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3790)
      4. org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3809)
      5. org.mozilla.javascript.ScriptRuntime.undefReadError(ScriptRuntime.java:3822)
      6. org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1507)
      7. org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1398)
      7 frames