natario1
08/04/2021, 10:56 AMandroid:configChanges="(everything)"
as suggested by compose team, so compose handles UI rotations. But I'm seeing issues with `SurfaceView`s in the compose hierarchy. Would love to have some insight about what's happening under the hoodAdam Powell
08/04/2021, 1:33 PMnatario1
08/04/2021, 2:08 PMSurfaceView
is involved (camera preview is rotated, exoplayer preview messed up). They only happen when config change is managed by compose, that's why I was asking for info. How does compose know that there was a config change?
To answer my original question, looks like `View`s are not recreated, they're just remeasured with swapped dimensions, then laid out and drawn in this rotated environment. In the surface world this means that the underlying surface is the same and you just get a new surfaceChanged
callback with new dimensions.Adam Powell
08/04/2021, 2:41 PMonConfigurationChanged
and that propagates to the LocalConfiguration
, plus the views hosting the compose content remeasure and relayout for the new available space.Adam Powell
08/04/2021, 2:43 PMromainguy
08/04/2021, 3:50 PMIn the surface world this means that the underlying surface is the same and you just get a newÂÂ callback with new dimensions.surfaceChanged
romainguy
08/04/2021, 3:51 PMSurfaceView
is measured and laid out again, so you should be getting a new Surface
romainguy
08/04/2021, 3:51 PMthen laid out and drawn in this rotated environment.
romainguy
08/04/2021, 3:52 PMnatario1
08/04/2021, 5:14 PMSurface
, updated with flipped size after a surfaceChanged
callback. I see now that this is not related to compose, though compose guidelines around android:configChanges
make you hit it.
Just for context, to fix camera preview I had to restart it in a DisplayListener, because I assumed that the display rotation can't change within the lifecycle of the surface. I fear I'll have to do something similar with video rendering issue.
Basically android:configChanges
was so discouraged that most people/libs have 0 experience with it, it seems. Thanks for helping guysromainguy
08/04/2021, 5:18 PMromainguy
08/04/2021, 5:18 PMupdated with flipped size after aÂÂ callbacksurfaceChanged
romainguy
08/04/2021, 5:18 PMSurface
object itself, what matters are the underlying buffers. The size change means you’ll produce new graphic buffers at the new dimensionsromainguy
08/04/2021, 5:19 PMSurfaceView
should properly handle size changes, either because of rotation, or simply because of a layout changenatario1
08/04/2021, 5:56 PM