setSurface

fun setSurface(surface: Surface?)

Replaces the display Surface without replacing this renderer or its paired decoder.

Replacing a non-null Surface never waits for a frame to finish drawing. The drawing thread picks it up at its next lock. Passing null waits until no canvas is locked on the old Surface, which SurfaceHolder.Callback.surfaceDestroyed requires, but for one second at most: a lock can itself be waiting on the main thread, and then the wait would never end. Giving up is reported as RendererEvent.SurfaceLost.