Skip to content

[Android] Flutter 3.19 beta - Widget freezes on resize #14

Closed
@timbotimbo

Description

@timbotimbo

Is there an existing issue for this?

  • I have searched the existing issues

Unity version

  • I am using Unity 2022.3 LTS

Common issues

  • I have checked the common issues

Flutter version

3.19.0-0.4.pre

Description

@jamesncl
Given that you seem to be more experienced in android development, I hope you have some insight.

I was testing the flutter 3.19 0.4-pre beta, to see if the fix for #12 was included.

However I found a new bug that affects the widget on resizing.
Run your example, and trigger the keyboard to open, or the screen to rotate.

The widget is now frozen, with this error spamming the console:
I/ImageReaderSurfaceProducer(16480): Skipped frame because resize is in flight.

The cause seems to be this PR flutter/engine#47946.

  • In short: Flutter used to rebuild the Virtual Display when it was resized, but now it calls a resize function on Android >= 12 instead.
 @TargetApi(31)
  private void resize31(
      View embeddedView, int width, int height, final Runnable onNewSizeFrameAvailable) {
    renderTarget.resize(width, height);
    // On Android versions 31+ resizing of a Virtual Display's Presentation is natively supported.
    virtualDisplay.resize(width, height, densityDpi);
    embeddedView.postDelayed(onNewSizeFrameAvailable, 0);
  }

Which at first glance seems great as it might solve some random bugs of unity becoming invisible on keyboard/screen rotations.
However a resize now simply breaks the widget as either Unity or this widget don't seem to handle this resize properly.

Given that the PR calls a resize function, maybe there is some kind of event or callback that we can listen to?

Video

These videos use the reproduction project I used for the other issue, but the difference doesn't really matter here.

3.16.5 3.19.0-0.4-pre
3.16.mp4
3.19.mp4

Minimum reproducible example (MRE)

  • Enable autorotation and all screen orientations in the player settings of the example project.

  • Run in Flutter and rotate the screen.
    This works fine in Flutter 3.13, 3.16 etc., but not in the new 3.19 beta versions.

  • Alternatively, put a textfield over the unity widget and tap it to open the keyboard.
    I added a branch with a textfield to my reproduction repo which doesn't need unity to be installed.

What platforms are you seeing the problem on?

Android

Devices

Samsung Galaxy S20FE, Android 13. Likely any other device on android >= 12.

Anything else?

Flutter should release a new version (3.19 or 3.20?) this month.
If this makes it in, this widget is broken on both 3.16 and the next version.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions