Merge "Guard against crash due to null surface" into pi-dev