Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using painterResource to prevent unnecessary recompositions #13887

Open
3 tasks done
Sagar0-0 opened this issue Jan 8, 2025 · 2 comments
Open
3 tasks done

Avoid using painterResource to prevent unnecessary recompositions #13887

Sagar0-0 opened this issue Jan 8, 2025 · 2 comments

Comments

@Sagar0-0
Copy link
Contributor

Sagar0-0 commented Jan 8, 2025

Guidelines

  • I have searched searched open and closed issues for duplicates
  • I am submitting a bug report for existing functionality that does not work as intended
  • This isn't a feature request or a discussion topic

Bug description

Example usage:

  1. Go to creating a call link.
  2. Click on the Toggle Button.
  3. this should recompose only the toggle row as the state of the whole row changes.
  4. But, clicking on the the toggle button will also recompose the 3 rows below, as they include the Icons, which are recomposed because of the painterResource composable function.

As we are still slowly moving toward jetpack compose and not a large part of the codebase is migrated, I believe it is good time to use ImageVector instead of relying on painterResourceif not required.

I am happy to take this little migration forward and would love to contribute in more impactful changes in future.

Screenshots

Using painterResource :

Signal.CreateCallLinkBottomSheetDialogFragment.kt.Signal.Signal-Android.main.2025-01-08.12-08-47.mp4

Using vectorResource :

Signal.CreateCallLinkBottomSheetDialogFragment.kt.Signal.Signal-Android.main.2025-01-08.12-11-33.mp4

Device

Realme GT NEO 3T

Android version

14

Signal version

7.29.0

Link to debug log

NA

@alex-signal
Copy link
Contributor

Nice find. For small things like this we don't need a full issue / follow-up, you can just go ahead and submit a PR with some conversions. Better to do this kind of thing in bite sized chunks rather than all in one large change-set as well. We'll begin using ImageVector.vectorResource where applicable in the future as well.

@Sagar0-0
Copy link
Contributor Author

Sagar0-0 commented Jan 8, 2025

Great, thanks for the clarification.

I will create a new TabRow with ImageVector(icon param name(no default value/ mandatory param)) so that it won't conflict with the existing TabRow with the icon param name and default Painter values as null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants