Runtime Error: /users/jenkins/... widget_tableview.lua:920: attempt to perform arithmetic on field 'contentheight'

Hello all,

I have, on some occasions, this error when running my app on Android phone. The error aborts the app. The error message is,

/Users/jenkins/slaveroot/workspace/Templates/label/android/subrepos/widget/widgetLibrary/widget_tableview.lua:902: attempt to perform arithmetic on field ‘contentHeight’ (a nil value)

The above error has so far appeared on the following devices,

Samsung S3, Android 4.3

LG G4, Android 6.0

It does not yet appear on the Cornoa SDK Simulator 2016.2906 on MS-Windows 7, which I am using. I searched the forum, but did not come across any previous threads with the above error message.

I checked through all the lua files for the app, and confirm none of the lua files uses TableView  widget specifically. A direct string search of the  tableview on all the lua files yield nothing.

Please help to advise.

Thank you.

Luan

I would use height instead of contentHeight

You may be using something that uses a tableView like a pickerWheel. Are you using 2906 for your device builds?

Hello Scott and Rob,

Thanks for your prompt response. I was thrown off-course in my troubleshooting earlier, as I was following the “lead” in the error message. Also, the error message, at first, seems to be random.

Yes. Rob, I did use the _ newPickerWheel _ in one of my scenes. (But I didn’t know that the PickerWheel uses TableView until now.)

I am sorry to bother you folks, as I believe I have found the cause of the error. Let me explain.

(1)   First, the error message only appear “randomly” on the various Android devices. It does not appear on the Corona SDK Simulator on MS-Windows7, which I use to develop and build for Android.

(2)   This led me to realise that the difference in testing on the Android devices and Simulator is,

       I did not test the Android back button on the Simulator as the back button does not work on the Simulator (on MS-Windows)

(3)   This led me to repeatedly test my “Go Back” (_ newButton ), “Back” ( newTabBar _) and the Android Back button (on actual Android devices).

       There is a total of seven scenes. The user moves about the scenes using the various user interactions as above. But the Android back button was not thoroughly tested, as this method was added last and it was not on the Simulator.

(4)   Finally, a pattern (of moving from scene to scene) emerges that triggers the error message. I am now able to reproduce the error.

The culprit found was a composer.removeHidden() that was there during an earlier testing, as I am not familiar with composer, I copied and paste from a number of places, to try out the various composer function calls. One instance was left in the final code. It did not cause any problem during the Simulator test, and it only causes problem (now I know) when a certain sequence of moving from scene to scene, using the Android back button (but not the “Back” (newTabBar) nor the “Go Back” (newButton) ).

I am now able to confirm that it has been fixed. Please help to close this thread.

Thank you for your time.

Regards, Luan

PS> Now, I have added another key to “keyName” to test the Android back button using the Simulator, besides the actual “back” key which does not work on the Simulator on MS-Windows. This would ensure that codes in the onKeyEvent(event) would be better tested in future during the development and test phase.

I would recommend anyone using the Simulator on MS-Windows to build for Android to do likewise. Hope this helps.

Under the main menu at the top of the simulator, there is an option called “Hardware” and one of the menu option is “Back” (on macOS you have to have an Android skin selected). This will simulate the Android “back” button.  But your idea to bind a keyboard button to do the same thing will make testing your back code better.

composer.removeHidden() is like composer.removeScene() in that it purges scenes that are not on the screen. However I think it doesn’t do a full un-require of the module like composer.removeScene() does. Depending on how much work you’re doing in the scene’s main chunk (not inside an event function like scene:create() or scene:show(), things might not be coming back to the state  you expect them to be in.

Glad you solved it.

I would use height instead of contentHeight

You may be using something that uses a tableView like a pickerWheel. Are you using 2906 for your device builds?

Hello Scott and Rob,

Thanks for your prompt response. I was thrown off-course in my troubleshooting earlier, as I was following the “lead” in the error message. Also, the error message, at first, seems to be random.

Yes. Rob, I did use the _ newPickerWheel _ in one of my scenes. (But I didn’t know that the PickerWheel uses TableView until now.)

I am sorry to bother you folks, as I believe I have found the cause of the error. Let me explain.

(1)   First, the error message only appear “randomly” on the various Android devices. It does not appear on the Corona SDK Simulator on MS-Windows7, which I use to develop and build for Android.

(2)   This led me to realise that the difference in testing on the Android devices and Simulator is,

       I did not test the Android back button on the Simulator as the back button does not work on the Simulator (on MS-Windows)

(3)   This led me to repeatedly test my “Go Back” (_ newButton ), “Back” ( newTabBar _) and the Android Back button (on actual Android devices).

       There is a total of seven scenes. The user moves about the scenes using the various user interactions as above. But the Android back button was not thoroughly tested, as this method was added last and it was not on the Simulator.

(4)   Finally, a pattern (of moving from scene to scene) emerges that triggers the error message. I am now able to reproduce the error.

The culprit found was a composer.removeHidden() that was there during an earlier testing, as I am not familiar with composer, I copied and paste from a number of places, to try out the various composer function calls. One instance was left in the final code. It did not cause any problem during the Simulator test, and it only causes problem (now I know) when a certain sequence of moving from scene to scene, using the Android back button (but not the “Back” (newTabBar) nor the “Go Back” (newButton) ).

I am now able to confirm that it has been fixed. Please help to close this thread.

Thank you for your time.

Regards, Luan

PS> Now, I have added another key to “keyName” to test the Android back button using the Simulator, besides the actual “back” key which does not work on the Simulator on MS-Windows. This would ensure that codes in the onKeyEvent(event) would be better tested in future during the development and test phase.

I would recommend anyone using the Simulator on MS-Windows to build for Android to do likewise. Hope this helps.

Under the main menu at the top of the simulator, there is an option called “Hardware” and one of the menu option is “Back” (on macOS you have to have an Android skin selected). This will simulate the Android “back” button.  But your idea to bind a keyboard button to do the same thing will make testing your back code better.

composer.removeHidden() is like composer.removeScene() in that it purges scenes that are not on the screen. However I think it doesn’t do a full un-require of the module like composer.removeScene() does. Depending on how much work you’re doing in the scene’s main chunk (not inside an event function like scene:create() or scene:show(), things might not be coming back to the state  you expect them to be in.

Glad you solved it.