Merge "wait for flush to finish before returning setSurface" into lmp-dev