One of the official Google samples for the Camera2 API suffers from the same BufferQueue has been abandoned problem as is seen in:
Are you waiting for the camera's onClosed state callback method to be invoked, before exiting onPause?
Until that callback fires, the camera may still have pending work to do, and the definition of close() is to finish up all pending capture requests before shutting down the device. This can be sped up by calling abortCapture() before calling close().
Some devices (like the N5 and N6) currently block the close() call so that when it returns, all the pending work is done, but this is an implementation detail that I think our sample inadvertently relies on today.
However, we generally want to allow apps to call close() and leave onPause() immediately, to avoid hanging the UI thread on waiting for the camera hardware to shut down. But this isn't yet reality today.
In other words, close() is supposed to be asynchronous, and isn't on all devices. But we'd like it to be possible for you to fire and forget it, so these error messages need to be addressed on the camera device's side (not spam the log when the repeating request target goes away mid-operation).
The other reason just calling close() and exiting onPause() isn't recommended today is that it will prevent other apps from opening the camera in their onResume() calls, which will cause spurious errors when switching between camera apps.
So to summarize:
For now: Wait for CameraDevice.StateCallback#onClosed to be invoked before exiting onPause() after calling CameraDevice#close().
At some future point: Will be safe to just call close() and exit onPause; the framework will properly allow the next app to connect and not spam your log. Sorry this isn't the state today!
As to the actual question - "when is a TextureView's 'Consumer side' closed", I don't know the exact timing, but it is certainly after onPause returns.
Roughly, TextureView contains a GL surface, and once the UI for the activity is no longer visible, those resources are torn down. Once that happens, the SurfaceTexture given out by the TextureView is no longer valid, and any existing users of that SurfaceTexture (or Surfaces made from it) will start receiving those errors. The method TextureView.SurfaceTextureListener.onSurfaceTextureDestroyed should be invoked by TextureView right before this happens.
So as an alternative, you may be able to return false from onSurfaceTextureDestroyed to avoid having it be released during UI teardown, and instead wait for onClosed to fire, and then in onClosed release the TextureView's SurfaceTexture yourself. However, I'm not quite familiar enough with the UI/View side of things to know for sure this'll work, and since some of the underlying native surfaces are released either way, you might still see the abandoned errors with this approach.
If you're curious, the top levels of the relevant code are in TextureView , especially the destroySurface method, though there's a lot you'd need to understand about the whole Android UI system to sort out when exactly the destroySurface method is invoked, and what its effects are.