transition.lua:1099: attempt to index local 'targetObject' (a nil value)

@sgs, the question is…why the code you post here doesn’t give an error? it should. your removing an object in midle of a transition, so the object is not there anymore and you didn’t cancel the transition, it should give an error. 

in your case did you tried canceling your transition? the only problems i had with transitions were not canceled them before i remove their objects.

Can you produce a simple test case that fails?  That would be really helpful.

Rob

I havent tested it but what carlos says makes all sense, unless the transition or display.remove has built in checks for it.

I assume transition library handles object deleted as that would be a common noob mistake.

FYI, I only use fadeIn() and fadeOut() to show and hide layers that are always memory resident.

I wish it was that simple Rob!  I am only seeing these logged with 3100 and not 3086, has there been any transition library changes between those two versions?

Is transition library code available anywhere?

if you change the code to removeSelf()  instead of display.remove() the code still works. Corona must added that “check in” on the transition code. this is a good policy? it will be way harder to catch bad coding and i guess will be way slower since it will check 30/60 times per second if that object exists.

Aug 18, 2016 was the last update.

I looked at the code and the only way to get that error is if you pass a nil in for the object to fade. However, this is a situation where we shouldn’t allow it to error. I’ll see if we can harden that code to prevent it.

I have filed a bug report for it.

Rob

@carlos, transition library is too expensive for lots of animations.  I only use it for UI objects.

Are you sure on that Rob? Because

local obj = nil transition.fadeOut( obj, {time=1000} )

gives a completely different (and the one I would expect) error

?:0: attempt to index a nil value stack traceback: ?: in function 'fadeOut'

perhaps find somewhere “clever” to insert the following code, looking/monitoring for weird/corrupted values:

for i,tran in pairs(transition.\_transitionTable) do print("TRANSITION # " .. tostring(i)) for k,v in pairs(tran) do print(" ", k, v) if (k == "\_target") then -- is v nil? does v == obj? etc end end end

assumption is that ‘targetObject’ would be a function-local reference to ‘aTransition._target’, used internally in some way.

maybe if u can spot corruption in the transition table then that ‘explains’ corruption in the function-local which holds a copy of it?  (tho doesn’t explain corruption of the table)

otoh, if table appears non-corrupt, and just local ‘targetObject’ is corrupt, then likely there’s some obscure code-path that ‘accidentally’ leaves that local nil (instead of table value).

It would be helpful if you posted your actual code from your call instead of a test case that’s not actually emulating your code.  There is a condition that will cause the error your getting, but there are other reasons why that sample code fails like it does.

Rob

@Rob, as you know I am logging errors from game in my DB and as this is production code I do not get a meaningful stack trace, module or line number.

I wish I could isolate it but as is always the case with large projects with a large install base on many thousands of different devices this is just not possible.  I just checked and I have over 200 references to fadeOut().

I appreciate you wanting a real simple test case but life (in my case) is not that simple.

The full error is - so I assume it is in a callback somewhere?

/Users/jenkins/slaveroot/workspace/Templates/label/android/subrepos/transition/transition.lua:1099: attempt to index local 'targetObject' (a nil value) stack traceback: /Users/jenkins/slaveroot/workspace/Templates/label/android/subrepos/transition/transition.lua:1099: in function 'fadeOut' ?: 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\>

How many occurrences of transition.fadeOut() do you have?

Rob

Hundreds… and hundreds of fadeIn() too.  Any time a UI object animates alpha I use them.

In daily build 3109, we tightened up the code that would cause this error if a nil object was passed in. @sgs, I’m pretty sure you’re using that version or later. Did this address the error?

Thanks

Rob

I’ve only just released (currently on 5% staged roll out) with 3109 so I will let you know on this and the ANRs.  Still waiting on the Facebook ANR fix from Perry too.