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

Crash when switching screens on Android folding phone #114868

Open
SnowZero opened this issue Nov 8, 2022 · 9 comments
Open

Crash when switching screens on Android folding phone #114868

SnowZero opened this issue Nov 8, 2022 · 9 comments
Labels
c: crash Stack traces logged to the console c: fatal crash Crashes that terminate the process e: OS-version specific Affects only some versions of the relevant operating system engine flutter/engine repository. See also e: labels. found in release: 3.3 Found to occur in 3.3 found in release: 3.4 Found to occur in 3.4 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-android Android applications specifically team-android Owned by Android platform team triaged-android Triaged by Android platform team

Comments

@SnowZero
Copy link

SnowZero commented Nov 8, 2022

Steps to Reproduce

  1. Creating a new clean project
  2. run android emulator。7.6 Fold-in with outer display API 32
  3. Toggle folding

Demo

image info

flutter doctor
[✓] Flutter (Channel stable, 3.3.7, on macOS 12.5 21G72 darwin-arm (Rosetta), locale zh-Hant-TW)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.71.1)
[✓] Connected device (7 available)
[✓] HTTP Host Availability
@SnowZero SnowZero changed the title Crash when switching screens on Android folding phones Crash when switching screens on Android folding phone Nov 8, 2022
@exaby73 exaby73 added the in triage Presently being triaged by the triage team label Nov 8, 2022
@exaby73
Copy link
Member

exaby73 commented Nov 8, 2022

Triage report

I can reproduce this issue only on API 32. Seems to work correctly on API 33. Closing the device works for me while reopening it, crashes. Tested on the same emulator as OP mentioned above i.e. 7.6 Fold-in with outer display API 32

Error logs
E/AndroidRuntime( 6745): java.lang.IllegalArgumentException: Bounds must be non zero
E/AndroidRuntime( 6745):        at androidx.window.extensions.layout.FoldingFeature.validateFeatureBounds(FoldingFeature.java:125)
E/AndroidRuntime( 6745):        at androidx.window.extensions.layout.FoldingFeature.<init>(FoldingFeature.java:95)
E/AndroidRuntime( 6745):        at androidx.window.extensions.layout.WindowLayoutComponentImpl.getDisplayFeatures(WindowLayoutComponentImpl.java:227)
E/AndroidRuntime( 6745):        at androidx.window.extensions.layout.WindowLayoutComponentImpl.getWindowLayoutInfo(WindowLayoutComponentImpl.java:176)
E/AndroidRuntime( 6745):        at androidx.window.extensions.layout.WindowLayoutComponentImpl.onDisplayFeaturesChanged(WindowLayoutComponentImpl.java:168)
E/AndroidRuntime( 6745):        at androidx.window.extensions.layout.WindowLayoutComponentImpl.$r8$lambda$XkTA_n58b4Cw9wT3LKS4oQrPVvA(Unknown Source:0)
E/AndroidRuntime( 6745):        at androidx.window.extensions.layout.WindowLayoutComponentImpl$$ExternalSyntheticLambda0.run(Unknown Source:2)
E/AndroidRuntime( 6745):        at androidx.window.util.BaseDataProducer.notifyDataChanged(BaseDataProducer.java:49)
E/AndroidRuntime( 6745):        at androidx.window.util.PriorityDataProducer$$ExternalSyntheticLambda0.run(Unknown Source:2)
E/AndroidRuntime( 6745):        at androidx.window.util.BaseDataProducer.notifyDataChanged(BaseDataProducer.java:49)
E/AndroidRuntime( 6745):        at androidx.window.common.SettingsDevicePostureProducer.access$100(SettingsDevicePostureProducer.java:37)
E/AndroidRuntime( 6745):        at androidx.window.common.SettingsDevicePostureProducer$SettingsObserver.onChange(SettingsDevicePostureProducer.java:92)
E/AndroidRuntime( 6745):        at android.database.ContentObserver.onChange(ContentObserver.java:169)
E/AndroidRuntime( 6745):        at android.database.ContentObserver.onChange(ContentObserver.java:187)
E/AndroidRuntime( 6745):        at android.database.ContentObserver.onChange(ContentObserver.java:202)
E/AndroidRuntime( 6745):        at android.database.ContentObserver.lambda$dispatchChange$0$ContentObserver(ContentObserver.java:282)
E/AndroidRuntime( 6745):        at android.database.ContentObserver$$ExternalSyntheticLambda0.run(Unknown Source:10)
E/AndroidRuntime( 6745):        at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime( 6745):        at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 6745):        at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime( 6745):        at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime( 6745):        at android.app.ActivityThread.main(ActivityThread.java:7842)
E/AndroidRuntime( 6745):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 6745):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/AndroidRuntime( 6745):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
I/Process ( 6745): Sending signal. PID: 6745 SIG: 9
Lost connection to device.

@exaby73 exaby73 added c: crash Stack traces logged to the console platform-android Android applications specifically engine flutter/engine repository. See also e: labels. e: OS-version specific Affects only some versions of the relevant operating system c: fatal crash Crashes that terminate the process has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.3 Found to occur in 3.3 found in release: 3.4 Found to occur in 3.4 and removed in triage Presently being triaged by the triage team labels Nov 8, 2022
@SnowZero
Copy link
Author

SnowZero commented Nov 9, 2022

I have similar Firebase Crashlytics happening on product project,
I suspect the same problem

Android 12 Xiaomi MIX Fold

error log
FoldingFeature.java line 125
androidx.window.extensions.layout.FoldingFeature.validateFeatureBounds
Fatal Exception: java.lang.IllegalArgumentException
Bounds must be non zero

Fatal Exception: java.lang.IllegalArgumentException: Bounds must be non zero
       at androidx.window.extensions.layout.FoldingFeature.validateFeatureBounds(FoldingFeature.java:125)
       at androidx.window.extensions.layout.FoldingFeature.<init>(FoldingFeature.java:95)
       at androidx.window.extensions.layout.WindowLayoutComponentImpl.getDisplayFeatures(WindowLayoutComponentImpl.java:227)
       at androidx.window.extensions.layout.WindowLayoutComponentImpl.getWindowLayoutInfo(WindowLayoutComponentImpl.java:176)
       at androidx.window.extensions.layout.WindowLayoutComponentImpl.onDisplayFeaturesChanged(WindowLayoutComponentImpl.java:168)
       at androidx.window.extensions.layout.WindowLayoutComponentImpl.$r8$lambda$XkTA_n58b4Cw9wT3LKS4oQrPVvA(WindowLayoutComponentImpl.java)
       at androidx.window.extensions.layout.WindowLayoutComponentImpl$$ExternalSyntheticLambda0.run(WindowLayoutComponentImpl.java:2)
       at androidx.window.util.BaseDataProducer.notifyDataChanged(BaseDataProducer.java:49)
       at androidx.window.util.PriorityDataProducer$$ExternalSyntheticLambda0.run(PriorityDataProducer.java:2)
       at androidx.window.util.BaseDataProducer.notifyDataChanged(BaseDataProducer.java:49)
       at androidx.window.common.DeviceStateManagerPostureProducer.lambda$new$0$DeviceStateManagerPostureProducer(DeviceStateManagerPostureProducer.java:50)
       at androidx.window.common.DeviceStateManagerPostureProducer$$ExternalSyntheticLambda0.onStateChanged(DeviceStateManagerPostureProducer.java:2)
       at android.hardware.devicestate.DeviceStateManagerGlobal$DeviceStateCallbackWrapper.lambda$notifyStateChanged$2$DeviceStateManagerGlobal$DeviceStateCallbackWrapper(DeviceStateManagerGlobal.java:400)
       at android.hardware.devicestate.DeviceStateManagerGlobal$DeviceStateCallbackWrapper$$ExternalSyntheticLambda1.run(DeviceStateManagerGlobal.java:4)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loopOnce(Looper.java:211)
       at android.os.Looper.loop(Looper.java:300)
       at android.app.ActivityThread.main(ActivityThread.java:8271)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049)

@GaryQian GaryQian added e: device-specific Only manifests on certain devices P1 High-priority issues at the top of the work list and removed e: device-specific Only manifests on certain devices labels Nov 10, 2022
@PhRezende-eng
Copy link

PhRezende-eng commented Nov 30, 2022

@SnowZero Just you need is to open the build.gradle, the path for this file is: android/app/build.gradle.
After that have been opened the file, put this command at dependencies

implementation 'androidx.window:window:1.0.0'
implementation 'androidx.window:window-java:1.0.0'

I found the solution on stack overflow, see at: https://stackoverflow.com/questions/74163927/flutter-chrash-in-android-12l-with-no-interface-method-addwindowlayoutinfoliste

@gmackall
Copy link
Member

@SnowZero did the workaround mentioned by @PhRezende-eng work for you, or if not are you still able to reproduce this issue with the latest version of Flutter?

@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-android Owned by Android platform team triaged-android Triaged by Android platform team labels Jul 8, 2023
@zukecsie
Copy link

This issue still exists in Flutter 3.13.1

@mossmana
Copy link
Contributor

@mariamhas Was this a reported issue for the Wonderous app as well when getting large screen Tier 2 certified?

@mariamhas
Copy link

I was not able to reproduce this with Wonderous Android app running on an actual foldable phone, I suspect this may only happen in the emulator.

@mossmana mossmana added P2 Important issues not at the top of the work list and removed P1 High-priority issues at the top of the work list labels Oct 19, 2023
@xxfast
Copy link

xxfast commented May 27, 2024

Still reproducible in 3.22.1. More details from ADB in #149115

   Process: com.example.list_detail, PID: 5225
    java.lang.IllegalArgumentException: Bounding rectangle must start at the top or left window edge for folding features
    	at androidx.window.extensions.layout.FoldingFeature.validateFeatureBounds(FoldingFeature.java:128)
    	at androidx.window.extensions.layout.FoldingFeature.<init>(FoldingFeature.java:95)
    	at androidx.window.extensions.layout.WindowLayoutComponentImpl.getDisplayFeatures(WindowLayoutComponentImpl.java:341)
    	at androidx.window.extensions.layout.WindowLayoutComponentImpl.getDisplayFeatures(WindowLayoutComponentImpl.java:316)
    	at androidx.window.extensions.layout.WindowLayoutComponentImpl.getWindowLayoutInfo(WindowLayoutComponentImpl.java:265)
    	at androidx.window.extensions.layout.WindowLayoutComponentImpl.onDisplayFeaturesChanged(WindowLayoutComponentImpl.java:250)
    	at androidx.window.extensions.layout.WindowLayoutComponentImpl.$r8$lambda$CcdqSJgN0v7j8yjFplaR5_gC_ag(Unknown Source:0)
    	at androidx.window.extensions.layout.WindowLayoutComponentImpl$$ExternalSyntheticLambda0.accept(Unknown Source:4)
    	at androidx.window.common.DeviceStateManagerFoldingFeatureProducer.runCallbackWhenValidState(DeviceStateManagerFoldingFeatureProducer.java:148)
    	at androidx.window.common.DeviceStateManagerFoldingFeatureProducer.lambda$getData$0(DeviceStateManagerFoldingFeatureProducer.java:200)
    	at androidx.window.common.DeviceStateManagerFoldingFeatureProducer.$r8$lambda$aShjSiJsnArI0ZW6HG-0QPWddJk(Unknown Source:0)
    	at androidx.window.common.DeviceStateManagerFoldingFeatureProducer$$ExternalSyntheticLambda2.accept(Unknown Source:6)
    	at androidx.window.common.RawFoldingFeatureProducer.getData(RawFoldingFeatureProducer.java:71)
    	at androidx.window.common.DeviceStateManagerFoldingFeatureProducer.getData(DeviceStateManagerFoldingFeatureProducer.java:196)
    	at androidx.window.extensions.layout.WindowLayoutComponentImpl.onDisplayFeaturesChangedIfListening(WindowLayoutComponentImpl.java:397)
    	at androidx.window.extensions.layout.WindowLayoutComponentImpl.-$$Nest$monDisplayFeaturesChangedIfListening(Unknown Source:0)
    	at androidx.window.extensions.layout.WindowLayoutComponentImpl$NotifyOnConfigurationChanged.onActivityConfigurationChanged(WindowLayoutComponentImpl.java:415)
    	at android.app.Application.dispatchActivityConfigurationChanged(Application.java:576)
    	at android.app.Activity.dispatchActivityConfigurationChanged(Activity.java:1631)
    	at android.app.Activity.onConfigurationChanged(Activity.java:3180)
    	at android.app.ActivityThread.performActivityConfigurationChanged(ActivityThread.java:6096)
    	at android.app.ActivityThread.performConfigurationChangedForActivity(ActivityThread.java:6021)
    	at android.app.ActivityThread.handleActivityConfigurationChanged(ActivityThread.java:6366)
    	at android.app.ActivityThread.handleActivityConfigurationChanged(ActivityThread.java:6304)
    	at android.app.servertransaction.ActivityConfigurationChangeItem.execute(ActivityConfigurationChangeItem.java:55)
    	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
    	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139)
    	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96)
    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
    	at android.os.Handler.dispatchMessage(Handler.java:106)
    	at android.os.Looper.loopOnce(Looper.java:205)
    	at android.os.Looper.loop(Looper.java:294)
    	at android.app.ActivityThread.main(ActivityThread.java:8177)
    	at java.lang.reflect.Method.invoke(Native Method)
    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

@huycozy
Copy link
Member

huycozy commented May 27, 2024

This seems to be an issue on native side with androidx.window:window-java: https://issuetracker.google.com/issues/262411062?pli=1 (it's fixed, see https://issuetracker.google.com/issues/262411062#comment9)

auto-submit bot pushed a commit that referenced this issue Jun 18, 2024
…0, and Fix test failures blocking androidx upgrade (#149204)

PR to pave the way for flutter/engine#53001 to re-land

Summary: 
- Enforces use of Kotlin >= `1.7.0` (please see below note)
- Fixes ci failures that prevented the above PR from landing.

Details:

Because it landed initially, we are able to fake the roll in this PR to fix all the tests ([see my comment](#149204 (comment))).

Fixes all the tests that failed:
1. `module_test` failing on multiple platforms (3/9 of the failures). 
Failure is 
```
> Android resource linking failed
   ERROR:/b/s/w/ir/x/t/flutter_module_test.KECMXW/hello/.android/plugins_build_output/device_info/intermediates/merged_res/release/values/values.xml:194: AAPT: error: resource android:attr/lStar not found.
```

This is a rather unhelpful error message but some [folks online suggest](https://stackoverflow.com/a/69050529) that upgrading your `compileSdk` version fixes this.
These resolve when I remove the dependency on the long discontinued [package_info](https://pub.dev/packages/package_info) and [device_info](https://pub.dev/packages/device_info) packages, perhaps because they are transitively pulling in low `compileSdk` versions? This is unclear to me.

2. `module_custom_host_app_name_test` was failing for the same reason (another 3/9, or cumulative 6/9).
3. `tool_integration_tests_3_4` was a flake � (7/9)
4. `framework_tests_slow` needed a newer version of the Kotlin Gradle plugin (the flutter tool tells us this, so I just upgraded as suggested) and it resolved (8/9)
5.`android_preview_tool_integration_tests` needed newer AGP and KGP versions. I also refactored the tests, and bumped our error versions, fixing #142653.

**Note that the bump to KGP is not in line with our policy** - we didn't warn for `1.5.0-1.6.x` for a release (or at all) before dropping support. But I think it might still be justified:
- The bump to our androidx libraries unblocks ongoing Scribe work, and also includes a fix for a [memory leak](#129307 (comment)) and a [crash on folding phones](#114868 (comment)), among many other bug fixes.
- Gradle [doesn't test on half of that range](https://docs.gradle.org/current/userguide/compatibility.html#kotlin), and so we implicitly can't claim to support it either. More generally, our Java and Kotlin support ranges should probably strictly fall within what Gradle tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: crash Stack traces logged to the console c: fatal crash Crashes that terminate the process e: OS-version specific Affects only some versions of the relevant operating system engine flutter/engine repository. See also e: labels. found in release: 3.3 Found to occur in 3.3 found in release: 3.4 Found to occur in 3.4 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-android Android applications specifically team-android Owned by Android platform team triaged-android Triaged by Android platform team
Projects
None yet
Development

No branches or pull requests