Closed diegum closed 1 year ago
The only way around this is to opt out of config changes to stop the webview being destroyed and recreated.
Add this to your activity in the AndroidManifest
<activity
...
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
>
Description Unlike Google Chrome or Firefox, in which rotating the device while a video is playing in the browser doesn't alter the playback experience (the clip stays playing before, during and after the rotation,) the story is different with Jetpack Compose Accompanist WebView. I'm using the current version
0.31.3-beta
, which already resolves the issue about the navigation state (thanks!!) But the playing video will either start from the beginning (if the page features autoplay,) or stop playing, but staying ready to play from the beginning.Steps to reproduce
WebView
(at the time of this writing, it's the latest version0.31.3-beta
.)Expected behavior In spite of re-rendering the page, the video playback keeps its pace like if no rotation would have occurred.
Additional context I inspected the Accompanist implementation in version
0.31.3-beta
. I see thatWebView(...)
accepts afactory
that, given a context, returns a WebKitWebView
. If the factory isnull
, suchWebView
is created every time. I tried to provide myfactory
reusing the same WebKitWebView
after rotating, but the app crashed because thatWebView
already had a parent, besides leaking the context of the dismissed activity. I wish I could see a working sample passing thefactory
parameter. It seems a lot to me that the solution to my issue involves it.