Add extra checks to handle context lost.

I have some context lost errors those days.
Not a big change but I hope it can help...

** Seen on [Handling Context Lost](https://www.khronos.org/webgl/wiki/HandlingContextLost).