Fix for async texture loading

This code runs in a loop and it can fail.