Hi, I am regularly running into `StackOverlfowErro...
# compose-desktop
m
Hi, I am regularly running into
StackOverlfowErrors
originating in the compose runtime code that handles
Snapshots
. I suspect that an integer overflow on the snapshot id causes the code to run into a
StackOverflow
… This of course also means my code is causing many Snapshots to be created, but (I think) this makes sense as I have a desktop compose app with an animated
Tray
icon, and the application is running for long times. Has anybody experienced similar? Could it be my compose usage that’s the fault here?
m
Perhaps this is a hint from the system to tell you that some users simply find such constant animations annoying 😉.
🤣 1
1
m
I would put away your prejudice and personal preferences. I think there are various use cases for animated tray icons. Not only to indicate a particular state of you background app, but also maybe to show explicit information e.g. a system stats tray with the CPU load or a key metric for a system you are running. Maybe even a graph showing a window of the change over time. And even if I want to animate the tray icon just for fun or show a movie in there. Why not having some fun exploring frameworks 🙂
z
What is the stack trace in the exception? I don’t know why an integer overflow would cause that exception, that’s a completely different thing.
m
Hi, thanks for getting in touch 🙂 The integer overflow hypothesis is just that. a hypothesis as this is the time when the snapshot id is not monotonically increasing.. and actually the first time it is negative at all. But you are right, it might be a premature theory. Actually, as I wanted to enforce such an overflow the StackOverflow did not happen with the integer overflow. So my initial guess is indeed wrong. I don’t have the stacktrace at hand right now (will post it once it happens again), but it is basically happening on the recursive call of
SnapshotIdSet.set
(https://github.com/androidx/androidx/blob/androidx-main/compose/runtime/runtime/sr[…]Main/kotlin/androidx/compose/runtime/snapshots/SnapshotIdSet.kt) So the stack trace does not show a lot of interesting calls besides the function.
a
Surely an integer overflow can’t be the cause? That’s 2,147E9 integers for signed integer. Assuming snapshot every frame at a 60Hz, that’s 417 days.
m
I am pretty sure that an integer overflow happened. (had a break point there and the next id was exactly
Integer.MIN_VALUE
. I also did the calculation on the time, and came to a similar conclusion as you did @Arjan van Wieringen. That’s why I added the
Could it be my compose usage that’s the fault here?
in the initial message. It’s just a lot of state changes to get to this overflow. (but I guess, even if my code is not performant, the StackOverflow should not happen in the compose runtime) This also brings one to the conclusion that the tray icon is probably not the only thing here 😄 So it’s likely I overdo it in the code, and that very inefficiently. Will try to get a walking skeleton to reproduce. Still waiting for the stack trace to pop up…
z
Whether an integer overflow happened or not, that's separate from the stack overflow. They might be related, but it's probably still a separate bug.
👍 1
m
@Zach Klippenstein (he/him) [MOD] Once I have the stack trace, should I directly open a ticket in the google issue tracker?
z
Sure, and please post the ticket link here once you've done so
m
Ok, thanks for your responses and guidance! 🙂
Ticket: https://issuetracker.google.com/u/5/issues/370536104 Couldn’t distill a reproduction sample yet unfortunately.
👍🏻 1