Hey folks! Did anyone had an issue with their Comp...
# android
a
Hey folks! Did anyone had an issue with their Compose app flickering on tablets in landscape mode? Some users also reported flickering on Pixel 9 Pro Fold, but with emulators it flickers only on Pixel Large Tablet. I’m posting a video in a thread.
On the second video I’m rotating the screen (flashing moment). You can see how behaviour changes. If I go to App Info -> Aspect Ration and change it from App Default to Full screen or some other, everything works fine. Any hint is appreciated! Thanks!
p
Are you using
resizableActivity = false
or any other configuration to restrict the Activity to be full screen? That may be the problem. You have to take care of tablet screens now, after Android 15
a
Targeting SDK 35. Problem still there with
false
or
true
. If manually set the Aspect Ratio in App Info to Full screen, all works fine. I noticed also that the flickering increases in the speed. It seems like it’s recomposing all the time, unable to decide where to place the screen.
I think I found the issue. The app was locking the orientation per screen. This screen was locked to Portrait mode and for some reason on larger landscape displays we get this behaviour. If I remove the “locking”, it renders fine.
d
@Aleksandar Ilic Is it a social networking app? If it’s open source I would like to check it out
c
Also there is #C04TPPEQKEJ for those kind of questions.
☀️ 2
a
@Dumitru Preguza Yes, something like that. And it’s open source. Check it out here: https://github.com/PrimalHQ/primal-android-app
The issue is most likely with
onDispose
in
LockScreenOrientation
. I should probably add “locks” to every screen in navigation instead of relying on
onDispose
to revert back.
d
Thanks, is Nostr like SMTP, but for social networks instead of email ?
a
Yes, something like that. It is a protocol to make internet great again. 🚀
m
I guess you are doing something in your code to lock the screen orientation, if that is true, you should remove it, because android recreate your activity in landscape and you immediately force it to be portrait and changing that makes a new activity again and android tries to recreate it without locking again, it makes a loop.
d
@Aleksandar Ilic sounds more solid for social network apps than OAuth, until you loose your keys I would use it maybe in hybrid mode to repost my messages/posts to other platforms/servers
a
@Mohammad Fallah Exactly. I was able to fix it today. I was locking the screen to portrait and then in
onDispose
I was reverting to the original orientation (to avoid customizing every screen). The fix was to move to
SideEffect
and just set the screen orientation preference for every screen in the app. With this approach the flicker is gone and it works much better actually.
🙌 3
@Dumitru Preguza Keeping your keys safe is a challenge and they can be compromised easily if you are not careful. Right now, there is an app called Amber which stores your keys and then you can Login with Amber in other Nostr apps, but it’s not very popular. There is also remote signing and some other stuff. We’ll see how this evolves over time. The bottom line is that if you want to own your content, then you have to hold your keys and your data.
p
I would advise in the future to handle all orientations and screen sizes to get the maximum performance. You will be able to remove that code execution in the SideEffect {}, SideEffect runs at the end of every recomposition and this could be expensive for just checking the orientation. Perhaps LaunchEffect is less expensive
a
I agree! We are going to implement landscape support in the future along with support for foldables and tablets. And you are also right for the
SideEffect
. Switching it to the
LaunchedEffect
right now, thanks for the hint.
👌 1