Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter 3.19 breaks Unitywidget on Android 12+ screen transition, resize, screen rotation or keyboard open. #929

Open
timbotimbo opened this issue Feb 19, 2024 · 5 comments
Labels
android This issue is specific to the Android Platform. bug This issue refers to a bug in the plugin Flutter issue/bug Problem caused by Flutte that we can't fix Unity issue/bug Problem caused by Unity that we can't fix on our end.

Comments

@timbotimbo
Copy link
Collaborator

timbotimbo commented Feb 19, 2024

Description

Just a warning about using Flutter 3.19 on Android 12+.
The Unitywidget will break when a keyboard is openend or the screen is rotated.

It will end up spamming the following error:

E/BufferQueueProducer(17453): [ImageReader-1080x2000f22m4-17453-17](id:442d0000001b,api:1,p:1104,c:17453) dequeueBuffer: BufferQueue has been abandoned

You can only recover from this by fully removing the UnityWidget from the widget tree.

This does not happen on Android 11 and lower.

The Flutter 3.20 beta and master channel fix this bug, but that introduces another Unity bug.
Flutter now resizes the platform view and Unity can't seem to handle that. It will resize to the wrong size.

Workarounds

[UPDATE] Flutter 3.22 fixes the issue and can be used without workaround.

You've got 4 choices for now:

  • use Flutter up to 3.13.9
  • Use Flutter Up to 3.16.9 (with bug on Android < 8)
  • use useAndroidViewSurface: true
  • use 3.20 beta and don't use rotation or keyboard

Video

The red color is a container behind the unitywidget, to show when it is transparent or invisible.
The 3.19 videos were recorded on an earlier beta, but you get the same visual result on 3.19 stable.

S20FE Keyboard open videos

1: 3.162: 3.193: master (3.20)
S20FE_3.16_keyboard.mp4
S20FE_3.19_keyboard.mp4
S20FE_master_keyboard.mp4

Screen rotation videos

4: 3.165: 3.196: master (3.20)
S20FE_3.16_rotate.mp4
S20FE_3.19_rotate.mp4
S20FE_master_rotate.mp4

Versions

  • Unity: This applies to all Unity versions
  • Flutter: 3.19 stable
  • Android: Android 12 and up.
@timbotimbo timbotimbo added bug This issue refers to a bug in the plugin android This issue is specific to the Android Platform. Flutter issue/bug Problem caused by Flutte that we can't fix Unity issue/bug Problem caused by Unity that we can't fix on our end. labels Feb 19, 2024
@hdeppert
Copy link

Is the third workaround "use useAndroidViewSurface: true" really a workaround?

According to this issue (and two more related ones) this mode introduces more issues than working around, right?

As of now, what is the best setup for using Flutter with Unity and the widget and avoid rendering or touch input issues? Probably Flutter 3.13.9 + Unity with old input system ?

@timbotimbo
Copy link
Collaborator Author

timbotimbo commented Feb 20, 2024

Regarding useAndroidViewSurface.

Downsides:

  • Push/pop transitions look bad (flutter issue)
  • Issues with Flutter effects like blur or clipping.
  • Possible worse performance
  • Invisible on Android 6 & 7
  • In specific use cases it can pop over flutter on app resume (flutter issue)

Upsides:

  • New input system
  • Screen rotations and keyboard are smooth and not broken.
  • Doesn't have a chance to randomly turn invisible on resume or rotation.
  • Visible on Android 8 on Flutter >= 3.16

With these new issues popping up, the downsides are getting more and more acceptable.

I still prefer to stick with <= 3.13.9.
But my app does contain text instructions behind the UnityWidget on how to reset it, in case it turns invisible.

@TonyHoyle
Copy link

Glad I found this.. I was trying to work out why unity wasn't working at all on android 12+. Not just on resize - at all.. Downgrading flutter just not an option for us, we have functionality that relies on 3.19

Setting useAndroidViewSurface true fixed it and as far as I can see we haven't hit any downsides, it works just the same as before.

@timbotimbo timbotimbo changed the title Flutter 3.19 breaks Android 12+ resize on screen rotation or keyboard open. Flutter 3.19 breaks Unitywidget on Android 12+ screen transition, resize, screen rotation or keyboard open. May 14, 2024
@timbotimbo
Copy link
Collaborator Author

Fixes for this are included in Flutter 3.22

@hdeppert
Copy link

Fixes for this are included in Flutter 3.22

Thanks for the update! Do you have any update regarding your previous comment and recommendation on which version/setup should be used with which up-/downsides?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android This issue is specific to the Android Platform. bug This issue refers to a bug in the plugin Flutter issue/bug Problem caused by Flutte that we can't fix Unity issue/bug Problem caused by Unity that we can't fix on our end.
Projects
None yet
Development

No branches or pull requests

3 participants