Fixed
Status Update
Comments
il...@google.com <il...@google.com> #2
I got the same issue only in a Pixel 5 emulator running API 24. Adding a breakpoint in `loadImageBitmapResource` showed that it was an `OutOfMemoryException` being swallowed like you say. Would be handy if it threw the actual exceptions
ap...@google.com <ap...@google.com> #3
deleted
il...@google.com <il...@google.com> #4
I'm experiencing the same thing as well. In my case, it refuses to acknowledge this:
```kotlin
placeholder.xml
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android "
android:height="200dp"
android:viewportHeight="200"
android:viewportWidth="125"
android:width="125dp">
<path
android:fillColor="@color/black"
android:pathData="M 0,0 L 125,0 125,200 0,200z" />
</vector>
```
as a vector drawable when called in
```kotlin
painterResource(id = R.drawable.placeholder)
```
for an Image composable. Furthermore, this is happening on my emulator that has API 30 (Android R) so this issue might not be limited to APIs below or equal to 21.
```kotlin
placeholder.xml
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="
android:height="200dp"
android:viewportHeight="200"
android:viewportWidth="125"
android:width="125dp">
<path
android:fillColor="@color/black"
android:pathData="M 0,0 L 125,0 125,200 0,200z" />
</vector>
```
as a vector drawable when called in
```kotlin
painterResource(id = R.drawable.placeholder)
```
for an Image composable. Furthermore, this is happening on my emulator that has API 30 (Android R) so this issue might not be limited to APIs below or equal to 21.
Description
Build: AI-201.8743.12.41.6953283, 202011050241,
AI-201.8743.12.41.6953283, JRE 1.8.0_242-release-1644-b3-6222593x64 JetBrains s.r.o, OS Linux(amd64) v5.4.0-53-generic, screens 3440x1440
AS: 4.1.1; Kotlin plugin: 1.4.10-release-Studio4.1-1; Android Gradle Plugin: 4.1.1; Gradle: 6.5; NDK: from local.properties: (not specified), latest from SDK: 21.3.6528147; LLDB: pinned revision 3.1 not found, latest from SDK: (package not found); CMake: from local.properties: (not specified), latest from SDK: (not found), from PATH: 3.16.3
Affected version:
androidx.fragment:fragment-ktx:1.2.5
Note: It looks like all versions starting from 1.2+ are affected
Description
When you have view pager with nested fragment that shows menu it will crash if you try to access menu items from
onPrepareOptionsMenu
.Steps to reproduce
ViewPager
Fragment1
Fragment2
Fragment2
add nestedFragment21
and enablesetHasOptionsMenu(true)
, also add new menu specific to this fragmentFragment21
fromonPrepareOptionsMenu
Expected behavior
onPrepareOptionsMenu
should never be called if menu is not inflatedActual behavior
onPrepareOptionsMenu
Additional information
Looking through the changes I was able to pinpoint it to this behavior change:https://android.googlesource.com/platform/frameworks/support/+/4809e01d4153a5ba68cb68f36544baa1b90738c0
We are now also checking for parent menu visibility but only in
dispatchCreateOptionsMenu
, which means we would calldispatchPrepareOptionsMenu
with no menu inflated since we skipped it.Possible fix
dispatch*Menu
methods, ordispatchCreateOptionsMenu
Demo repository:
You can find repository with repro steps here:https://github.com/vovkab/fragment-menu-crash