Closed yellowHatpro closed 1 year ago
@thunderbiscuit is the issue there on other devices?? Can you confirm if it persists in your device/emulator?
Yes I think there are a few things at play here. This is a good place to discuss maybe what's wrong with this screen.
One of the issues with that screen (I have not deeply investigated this yet) is that it tends to trigger a lot of recompositions of the composables. I'm not sure why.
In theory, the main thread at that point does nothing else than get this address from the wallet. I don't know that sending this work to a background thread should "speed it up" per se. I'm also not sure which part is actually the slowest part of this process. Is it the call to the Wallet object? Or the addressToQR()
function? We could potentially pre-compute these things on a background thread as the user opens the screen and have it ready for them before they even click the button, which would then make it seem like the process was really fast. But even that feels a bit like over-optimization to me at the moment. Any thoughts on that?
On my devices and emulators it's not very slow to load this address (as opposed to navigating to the screen itself, which tends to be a bit slow I find).
I think generating the address is not a problem, but generating an image without thread switching will block the main thread. So what I am doing is, that I am calling the addressToQR()
function within a LaunchedEffect, which depends on the address itself, so the image generation is now bound to the address, which I don't think changes frequently or on its own.
I will try to check if there are other recompositions in the mentioned screen, but I suppose generating the QR in the background should be a safe call. Although, it might be noticeable to me because my device is a slow potato >﹏<.
Generating the image in the background is a good way to keep the UI from freezing, but I don't know how it can address your issue of the slowness of it directly.
Yeah slow won't be an appropriate word here. I was referring to the delay it causes.
https://user-images.githubusercontent.com/75999921/227734897-f0d64df6-f780-4a19-9c47-15ccb7dc674d.mp4
Fixes:
withContext(Dispatchers.IO)
and call the corresponding qr generation function there.Visible changes:
https://user-images.githubusercontent.com/75999921/227734881-3e8149fd-fd58-4f68-b866-c998a310e22c.mp4