soygabimoreno / Base

Base repo.
Apache License 2.0
14 stars 10 forks source link

Fix WebView Infinite Loading #5

Closed soyjimmysaenz closed 1 year ago

soyjimmysaenz commented 1 year ago

:tophat: What is the goal?

Fix the following scenario:

https://user-images.githubusercontent.com/1390475/208025219-2c9cc611-d7b4-4dad-8dab-921ca1eb6581.mov

Some related logs:

2022-12-15 22:50:34.900 15347-15347 chromium                soy.gabimoreno.debug                 E  [ERROR:aw_browser_terminator.cc(156)] Renderer process (15739) crash detected (code -1).
2022-12-15 22:50:34.923 15347-15347 chromium                soy.gabimoreno.debug                 E  [ERROR:aw_browser_terminator.cc(112)] Render process (15739) kill (OOM or update) wasn't handed by all associated webviews, killing application.

How to replicate?

  1. Go to the app's config and verify the domain gabimoreno.soy is linked to the app.
  1. Open a web link like this using a third party app like gmail (keep in mind app links on android open different apps depending on how the link was pressed), then verify the app is launched but suddenly the WebView Screen starts to blink multiple times until the app crashes.

Tested on:

  1. Google Pixel 6, android 13
  2. Xioami Redmi Note 8 pro, android 10
  3. Android Emulator, android 13

Why is this happening?

It seems the state holder encodedUrl is triggering infinite recompositions.

Disclaimer: It's my first time dealing with Compose on a production app 😅

Types of changes

The proposed solution is simple: just remove the state holder because IMO is not necessary. Perhaps this is not the ideal solution but at least this PR is a way to report the 🐞 and start a discussion with possible solutions 😀

After the workaround

https://user-images.githubusercontent.com/1390475/208026321-25d97fb4-6661-4875-af59-cf713a6087ee.mov