hi. i have a strange issue where requesting a focu...
# compose-desktop
z
hi. i have a strange issue where requesting a focus on a text view causes 100% cpu load. here is the code part that causes it:
Copy code
ChatAppWithScaffold(focusRequester = focusRequester, contactList = contacts, ui_scale = ui_scale)
//LaunchedEffect(contacts.selectedContactPubkey) {
//    focusRequester.requestFocus()
//}
if i comment out the part as shown above. the cpu load is gone. but i want my text input box to have focus. any ideas what i am doing wrong? why can't i simply set a text input to have focus without this hack anyway? any help please
a
Can you give us a reproducer?
z
not sure i can. is there a debug mode where i can get logging what compose does internally? and what causes recompositions and such?
but that particular issue does not seem to be recomposition.
my app is opensource. so you can try it. but since its a chat app you would need to add someone to get to the messages screen
anything i can do here?
a
A reproducer of the issue in as small piece of code as possible would really help.
Try removing portions of your code until the bug stops reproducing.
z
Copy code
//LaunchedEffect(contacts.selectedContactPubkey) {
//    focusRequester.requestFocus()
//}
if i comment this out, like this. then the issue goes aways
i try to make a small reproducer on the weekend. but i fear it might not show the issue. is there a ways to enable logging of what compose is doing internally, to see where it burns the cpu?
a
Not really
z
would be nice to have in the future. to see what is happening and what is triggering component updates and such