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

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!

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. 

Still i have that issue.please check and let me know.

What version of Corona SDK are you using?

Rob

2015.2731(2015.10.5)

Can you try a later daily build?

My mistake only.i added tableview into scrollview.sorry friends for my chilly mistake.