[Resolved] How to trace error from device back to lua code?

Hi,

we are getting an error:

Tue May 8 16:18:44 unknown UIKitApplication:archer[0x9953][3187] <notice>: Lua Runtime Error: lua_pcall failed with status: 2, error message is: ?:0: attempt to perform arithmetic on field 'x' (a nil value)<br>

and we cannot trace it back to the code - mostly because we can’t determine the scenario on how to get this error. It looks pretty random :confused:

Any tips on how to get more details?

Thanks,
Krystian [import]uid: 109453 topic_id: 26066 reply_id: 326066[/import]

Ahh the trickiest part of coding - things that work fine on simulator will nearly always throw a wobble on the actual device.

Judging from the error you’ve at least got some signs to follow. You’re attempting to do some arithmetic on (presumably) a display object’s x value. So you can at least begin to track things down to places you’re manipulating an x property of a display object.

Somehow that x value isn’t being assigned a value properly in the first place - hence it’s currently at nil, and you’re trying to do some arithmetic with it…

Just search in your entire project for anywhere you’re changing x values - painstaking I know, but it’s you’re only way through.

Good luck… [import]uid: 33275 topic_id: 26066 reply_id: 105498[/import]

Yeah… I’ve tried that.
From the amount of this errors being thrown I assume it’s somewhere in enterFrame [there’s a flood of this errors once they start], but to be honest, that didn’t help much.
There are at least 30 places where I manipulate .x variables and none of them seem to be problematic.
My other assumption is that there’s a removeSelf() issued, but this object is still in transition or something. Ahhh… I love this :slight_smile:

Thanks for help.

Aren’t there any tools one could use to trace errors like this?

The biggest problem I’ve got with it is that I have no clue how to get this error again - on purpose :wink: [import]uid: 109453 topic_id: 26066 reply_id: 105499[/import]

Unfortunately that’s the worst kind of bug - one that you just can’t replicate.

The fact that it’s happening regularly is a plus thing at least, and your line of thinking is correct about the enterFrame and number of error messages.

Unfortunately it’s going to be trial-and-error to at least work out the offending bit of code, you can then use the debugger and make sure the property is changing as you’d expect.

No tools to make this easier as far as I’m aware, but then again I quite like the satisfaction of eliminating bus and the old fashioned way :slight_smile: [import]uid: 33275 topic_id: 26066 reply_id: 105501[/import]

I’m not sure if this will help, anyway…

I use director… Director catches all errors and prints them separately under the name
[lua]-----DIRECTOR ERROR-----[/lua]
So what I did was replace the print statements in director with native.showAlert. Was pretty useful for me. [import]uid: 64174 topic_id: 26066 reply_id: 105531[/import]

It sounds like you are probably moving something in an enterFrame handler somewhere and the object has been removed ( atleast the visual part of it ) so it no longer has an X property. [import]uid: 119420 topic_id: 26066 reply_id: 105548[/import]

Do you have a Runtime listener tied to the accelerometer? That would explain why it appears on device and not in the simulator. [import]uid: 52491 topic_id: 26066 reply_id: 105563[/import]

Thanks guys.

I am not using accelerometer. I think it appears on the device more often than on simulator mostly because it’s more ‘hardcore’ to test it. Finger-tapping mayhem to be honest :wink: My trackball would not survive this.

In all of our objects we have a :remove() function, which cleans up the object. I have found one which didn’t remove enterFrame listener. Unfortunately, this would cause an error in a very specific scenario, very different from what we were doing when it happened.

Unfortunately due to the fact, that we can’t reproduce the bug, it’s difficult to say if it solved the problem.
It would be awesome if we could at least have a hint of where this error is coming from :confused: Well… lua has it’s advantages as well as disadvantages :confused: [import]uid: 109453 topic_id: 26066 reply_id: 105664[/import]

Today this error happened on simulator! :slight_smile:
Of course it was not enter frame huh…
Some clues we had [for example object clash detection didn’t work after this error] made us go totally wrong way. After solving the issue we are still not sure how that happened :wink:

Anyway… it’s solved.

Thanks [import]uid: 109453 topic_id: 26066 reply_id: 105911[/import]

Glad you got this working but sorry to hear it is still somewhat of a mystery.

Marking as resolved but if it comes back please bump.

Peach :slight_smile: [import]uid: 52491 topic_id: 26066 reply_id: 105981[/import]