grishka / appkit

Android app boilerplate + image loader
50 stars 17 forks source link

Unable to match desired swap behavior #16

Open LucasGGamerM opened 3 months ago

LucasGGamerM commented 3 months ago

Everytime an animation lags I get the '"Unable to match desired swap behavior" log entry. It started happening after upgrading to appkit 1.2.10 (1.2.9 didn't have the issue), and I am still unable to debug the weird animation hiccups that usually happen in the ripple animations. Do you have any clue as for where this issue might be originating, considering that the Mastodon app doesn't have it?

Thank you!

grishka commented 3 months ago

I've also seen this line many times but I'm unable to find it in AOSP. Maybe it comes from a proprietary GPU driver 🤔

grishka commented 3 months ago

I found it, there's a "the" in there

LucasGGamerM commented 3 months ago

Yes, it happens both in emulators and in on a lot of people's phones (including mine), and the weird thing is that it just straight up doesn't happen on the Mastodon app. Do you have any clue as for what could be the culprit?

grishka commented 3 months ago

I have no idea, it would require diving deep into libhwui, e.g. at least when and from where that function is called and what "preserve buffer" means. It may also be only happening in debug builds (debuggable=true), those just run slower than release builds in general.

LucasGGamerM commented 3 months ago

The only thing that bothers me is that the only time it happens is during the ripple animations, which just stop in the middle and look terrible.

It's a weird problem to have 😔

grishka commented 3 months ago

AFAIK ripple animations render on the render thread. A native-only thread that an app can't run any of its own code on, that is responsible for actually drawing things with OpenGL (and I believe Vulkan in some more recent Android versions on some devices). So it might be a bug in Android itself?

The only reason I can think of why it might want to switch surfaces (does this end up calling eglMakeCurrent?) is when you have more than one window in your app process. So it would draw into one window, then switch to the surface for the other one and draw it. Any overlays (popup menus, toasts, etc) count as separate windows too. It makes sense because there's only one render thread regardless of how many windows you have. But this is only a speculation that I'm too lazy to test.

LucasGGamerM commented 3 months ago

It's a nice clue to have, however I am not sure the reason for this ripple animation lag to start happening right after upgrading appkit from 1.2.9 to 1.2.10

Maybe it's another variable I am not considering?

grishka commented 3 months ago

I'm not sure it's related to appkit. It most probably isn't.

LucasGGamerM commented 3 months ago

In any case, you are a more experienced developer than me. Do you have any directions for where I should look for troubleshooting this?