Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

[Android] Remove workaround for excessive calls to AndroidView update #866

Merged
merged 2 commits into from
Nov 15, 2023

Conversation

jonnyandrew
Copy link
Contributor

@jonnyandrew jonnyandrew commented Nov 14, 2023

Problem

The update block of the composable AndroidView is run on every key press, whereas it should only run when a variable used inside the block is changed.

See #856 for more details.

Solution

There is currently a workaround in place for this bug but after some investigation using the Compose inspection tools available in AS Hedgehog, I found that the recomposition is triggered by the value of onError being detected as changed despite it being a static function reference.

I don't know why this causes the recomposition but replacing the function reference with a lambda function fixes the problem.

@codecov-commenter
Copy link

codecov-commenter commented Nov 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7836f40) 87.43% compared to head (eb9c100) 89.35%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #866      +/-   ##
============================================
+ Coverage     87.43%   89.35%   +1.92%     
============================================
  Files           165       86      -79     
  Lines         18840    15271    -3569     
  Branches       1033        0    -1033     
============================================
- Hits          16472    13646    -2826     
+ Misses         2074     1625     -449     
+ Partials        294        0     -294     
Flag Coverage Δ
uitests ?
uitests-android ?
uitests-ios ?
unittests 89.35% <ø> (+3.82%) ⬆️
unittests-android ?
unittests-ios ?
unittests-rust 89.35% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jonnyandrew jonnyandrew marked this pull request as ready for review November 14, 2023 16:58
Copy link
Contributor

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I also changed some code so the StyledHtmlConverter is only configured when needed in the compose example, which should clear the logs a bit.

Copy link

sonarcloud bot commented Nov 15, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@jonnyandrew
Copy link
Contributor Author

Thanks for the improvement @jmartinesp!

@jonnyandrew jonnyandrew merged commit 59d2a99 into main Nov 15, 2023
8 checks passed
@jonnyandrew jonnyandrew deleted the jonny/remove-workaround-for-excessive-recomposition branch November 15, 2023 09:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Composable AndroidView update block is run on every key press
3 participants