Runtime Error
/Users/jenkins/slaveroot/workspace/Templates/label/android/subrepos/widget/widget-Library/widget.lua:27: attempt to index field ‘?’ (a nile value)
This is the bug that has existed in my game for over a year. It doesn’t happen often, but considering that the very line number of the issue is listed in our Testing log, should be enough of a reason for CoronaLabs to fix it once and for all. NOTE: It would be fine if the widget simply exited from the routine under this condition - as players could then still play our game without it crashing.
Here are more details about how and what is happening to cause widget to crash. Please be advised that this bug in widget is very difficult to duplicate. And these details now represent details that, under the same conditions, will crash for other developers, too. The challenge is in fully understanding how widget interacts with our own code (and time-based listeners) and display groups. 05-20 19:44:17.021 25811-27891/? I/Corona: ERROR: Runtime error 05-20 19:44:17.021 25811-27891/? I/Corona: /Users/jenkins/slaveroot/workspace/Templates/label/android/subrepos/widget/widgetLibrary/widget.lua:27: attempt to index field ‘?’ (a nil value) stack traceback: [C]: ? /Users/jenkins/slaveroot/workspace/Templates/label/android/subrepos/widget/widgetLibrary/widget.lua:27: in function ‘removeWidgets’ /Users/jenkins/slaveroot/workspace/Templates/label/android/subrepos/widget/widgetLibrary/widget.lua:32: in function ‘removeWidgets’ /Users/jenkins/slaveroot/workspace/Templates/label/android/subrepos/widget/widgetLibrary/widget.lua:44: in function ‘method’ /Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:522: in function ‘remove’ ?: in function ‘displayRemove’ ?: in function ‘cleanUpGameObjects’ ?: in function ‘?’ ?: in function ‘listener’ /Users/jenkins/slaveroot/workspace/Templates/label/android/subrepos/timer/timer.lua:210: in function ‘method’ /Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:221: in function </Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:190> NOTE: I’ve reviewed my code where this happens and I found that, long ago, I attempted to prevent this from happening by checking if the scrollView object exists and if it does, simply send it to the scrollView:toBack without removing the group it is contained within. Also, when you see that the routine displayRemove is listed above, is this an error in widget or is it my own fw.displayRemove designed and implemented throughout the game to gracefully remove objects? Here is my own fw.displayRemove routine:
function fw.displayRemove(objOrGroup) if objOrGroup and type(objOrGroup)==“table” then
transition.cancel(objOrGroup)
display.remove(objOrGroup)
objOrGroup=nil
end
The only thing I can imagine that is happening is that calling my own routine to do this will remove the object or group “defined”, but because the variable containing the object is simply passed into this function, the original variable still contains a reference to the object that no longer exists. Nevertheless, shouldn’t widget know when its objects have been removed and stop attempting to operate? I also notice that my listener, which is called 30 frames-per-second, is the routine that kicks this off from my function ‘cleanUpGameObjects’. Is it possible that my function ‘listener’, which calls cleanUpGameObjects, is interrupting code that is running within widget, so that when widget begins running again, it has no reason to consider its own object has been removed in the middle of running? I’m grasping to consider every possibility.