android / android/nowinandroid

[Bug]: SearchRoute recomposing twice despite no state change ?

Open
#1,141 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
21.8k
Forks
4.6k
Avg merge
19h 20m
Merged PRs (30d)
2

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is there a StackOverflow question about this issue?

- [X] I have searched StackOverflow

### What happened?

I am not sure if this is a bug or not but as per basic Compose tenets , a composable will NOT recompose if its state remains unchanged from the first time it was composed .

I have attached a breakpoint and confirmed that when SearchRoute recomposes , none of its arguments have changed.

I am aware that this composable's callsite does gets recomposed multiple times , but I am unsure as to why does this cause its child composable (SearchRoute) to recompose .

This is strange specially because we are not passing unstable lambdas in SearchRoute , rather are relying on method references (which correctly remain the same upon recomposition).

Take a look at both these screenshots , and observe all references are similar. One screenshot was taken on first time around , and the second is of the recomposition

![image](https://github.com/android/nowinandroid/assets/26518062/9708700c-04f0-4732-b7be-91fc09c36693)
![image](https://github.com/android/nowinandroid/assets/26518062/97fcdd6c-47a1-469b-93f3-ded40e84dea9)

### Relevant logcat output

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

Reproduce the report in the app with a breakpoint in SearchRoute and observe the callsite's repeated recompositions. Compare SearchRoute's arguments and method references across runs, then determine whether the observed recomposition is expected; done means the cause is documented or a narrowly scoped fix is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.