If you’re getting two OnBecameInvisible’s without any OnBecameVisible between them, the solution is to record if you’ve done the onBecameInvisible already:
This assumes that there’s an actual buggy behaviour. If what’s actually happening is that the object rapidly becomes invisible, visible and then invisible again, you’ll have to do some kind of time-based check: