Fixed bug in render thread safety