Runtime Error: "Attempt to perform arithmetic on field 'contentHeight' (a nil value)"

We have had our app in the app store for while using Corona. 

I am currently on build: Version 2013.2100 (2013.12.7)

I have seen this bug in the past when jumping to a newer version of Corona. I have held back but now am making the jump to widget 2.0. 

Here is the error getting thrown:

_ Corona Simulator Runtime error _

_ File: ? _

Attempt to perform arithmetic on field ‘contentHeight’ (a nil value)

_ stack traceback: _

    [C]: ?

_     ?: in function ‘_manageRowLifeCycle’ _

_     ?: in function <?:516> _

_     ?: in function <?:218> _

So here is the deal. We jump from one scene to the next. Call it the home page to secondary page. On first load if you go from home page to secondary page it works fine. Then we have a back button to go back home. That works great. Then when you select to go the secondary page again this is where it breaks. 

I have googled :_  ‘_manageRowLifeCycle’ _

And it looks like on gitHub that is the part of the behind the scenes widget code. 

I am 99% positive it is a Corona bug. I have tableviews, scroll views, widget buttons, etc. 

Please let me know. Our app has been a case study in corona and we are kind of stuck!

P.S. Earlier I meant to say we just went through Graphics 2.0 Transition not Widget 2.0 transition

Also I just went back through my code again!

The only thing I have seen so far might be from our past Widget 2.0 transition. 

In the Widget 2.0 Migration guide you will see it says no more: scrollView:takeFocus()

but we still have that in our code. 

But on the actually doc in the API found here:

http://docs.coronalabs.com/api/type/ScrollViewWidget/takeFocus.html

it shows that it is still in. IDK…

P.S. Earlier I meant to say we just went through Graphics 2.0 Transition not Widget 2.0 transition

Also I just went back through my code again!

The only thing I have seen so far might be from our past Widget 2.0 transition. 

In the Widget 2.0 Migration guide you will see it says no more: scrollView:takeFocus()

but we still have that in our code. 

But on the actually doc in the API found here:

http://docs.coronalabs.com/api/type/ScrollViewWidget/takeFocus.html

it shows that it is still in. IDK…

did you ever figure this out. I’m getting this: “Attempt to perform arithmetic on field ‘height’ (a nil value)” when I return to a game level after going out of it temporarily (without purges or other hard nullification) to change something in the profile section. as in your example, there is no issue with performing math on height unless you leave and return…

I get this error when from a scene with a tableview I show an overlay with a scrollview. It only goes wrong when both tableview AND scrollview have sufficient content to scroll AND I add a row to the the tableview. Pretty obscure hey?

I have raised a bug - so fingers crossed.

@mkelly:  ““Attempt to perform arithmetic on field ‘height’ (a nil value)”” is a different error than the one being reported.  If you look in your console log, you should set a stack trace that gives you more information including line numbers where things went wrong.  Before anyone can help you we need to know what that says and see your code around the line numbers listed.

If you don’t know how to read the console log, please read: http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/

@andrew69, the bug listed at the top has been fixed for a while.  What version of Corona SDK are you using?  Like @mkelly, can you post the full error from the console log?

Thanks

Rob

it appears that mine occurred from purging a scene where they choose an avatar from a scrolling set of characters. once I removed the widget library for the scrollview when purging the avatar scene, the random errors in the game level went away.

local widget = require(“widget”);

local widgetTableNumber = package.loaded.widget

function scene:didExitScene( event )

local group = self.view

package.loaded[ widgetTableNumber] = nil

timer.performWithDelay(1, function() collectgarbage(“collect”) end)

collectgarbage(“step”)

collectgarbage()

end

I purged the avatar scene on entering the game level after that, and all was well… I hope this helps @andrew69.

Hi Rob,

Sorry for the delay but I am in the UK.

I am using yesterdays daily build but I found the fault on 2189. I raised the bug (Case 33391) with a full sample which demonstrates the problem.

From the console:

Version: 3.0.0

Build: 2014.2332

2014-06-10 08:01:06.241 Corona Simulator[2930:507] Runtime error

?:0: attempt to perform arithmetic on field ‘contentHeight’ (a nil value)

stack traceback:

?: in function ‘repositionY’

?: in function <?:1148>

(tail call): ?

/Users/andrewj/Desktop/Bug/scene1.lua:29: in function ‘_onRelease’

?: in function ‘?’

?: in function <?:677>

?: in function <?:218>

 

Thanks.

@mkelly: Hi, it seems that your error is different from mine. I did try your solution (thanks for giving it to me) but it had no effect. I must throw myself on the mercy of the fine people at Corona Labs unless this fine community can help.

Andrew

Andrew, its it still present in the latest daily builds?  There have been quite a few widget fixes since 2189.  We don’t go back and patch the public build.  It’s likely that what you’re encountering could have been fixed already.  Is there a reason you’re staying with 2189?  (and just to make sure you’re aware, there is a 2189a that addresses a build problem for iOS that Apple is rejecting on…)

Rob

Hi Rob,

I am using daily build 2332 and the problem still exists.

Thanks,

Andrew

Are you getting the error with the same line numbers?

Do you by any chance have a copy of the widget library in your project?

Rob

Hi Rob,

I have no idea how to have a copy of the widget library in my project, I am just using the local widget = require( “widget” ) method of including it in each scene, so I guess the answer is no.

The stack trace when using 2189 is below - the line numbers are different so I guess that this proves that I am using a newer, supposedly fixed, version of the widget library.

Thanks, I do hope that we get to the bottom of this - it will require a major re-work of my design to use a mat hod that works.

Andrew

stack traceback:

?: in function ‘repositionY’

?: in function <?:1116>

(tail call): ?

scene1.lua:29: in function ‘_onRelease’

?: in function ‘?’

?: in function <?:424>

?: in function <?:218>

I see you’ve filed a bug report on this.  Thank you. #33391

Rob

Woop! Fixed in Daily build 2014.2363. I tested it and it works fine.

Thanks Team!

did you ever figure this out. I’m getting this: “Attempt to perform arithmetic on field ‘height’ (a nil value)” when I return to a game level after going out of it temporarily (without purges or other hard nullification) to change something in the profile section. as in your example, there is no issue with performing math on height unless you leave and return…

Hi Rob, about issue on andrew69 post now it fixed yet? it cause from what ? if i still used 2014.2189, how to fixed it ? hope can u help this one . thanks

Hi, Can u help me this one .

Runtime error

        ?:0: attempt to perform arithmetic on field ‘contentHeight’ (a nil value

)

stack traceback:

        [C]: ?

        ?: in function 'repositionY’

        ?: in function <?:1116>

        (tail call): ?

-

this one fix yet? do you know why it error like this? it cause from what?

@soy.tola.rupp, what version of Corona SDK are you using?  As far as I know this has been fixed in Daily builds and will be available in the next public build.