Obsolete
Status Update
Comments
nk...@gmail.com <nk...@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit b9b1326edfe38588a9882e1ee624798966c5686a
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Oct 06 16:49:53 2021
Clear focus on Fragments animating out
Since moving to the new state manager, fragment now explicitly handle
focus where in the old world they could ignore it altogether. This
change has the side effect that other things affected by focus (i.e.
soft keyboard input) are affect as well. In particular when we
requestFocus we update the input request, but since we never clear it
users have to manually remove the input.
When we are animating a fragment view out, since we will no longer be
using the exiting view, let clear the focus of before we remove it from
the fragment.
RelNote: "The keyboard will now close automatically when going from
a fragment with an open keyboard to a fragment with a recycler view."
Test: tested in sample app from bug
Bug: 196852211
Change-Id: I8b842dd9a421cfbc9189014b802f5e4b6b9c2a47
M fragment/fragment/src/main/java/androidx/fragment/app/SpecialEffectsController.java
https://android-review.googlesource.com/1847143
Branch: androidx-main
commit b9b1326edfe38588a9882e1ee624798966c5686a
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed Oct 06 16:49:53 2021
Clear focus on Fragments animating out
Since moving to the new state manager, fragment now explicitly handle
focus where in the old world they could ignore it altogether. This
change has the side effect that other things affected by focus (i.e.
soft keyboard input) are affect as well. In particular when we
requestFocus we update the input request, but since we never clear it
users have to manually remove the input.
When we are animating a fragment view out, since we will no longer be
using the exiting view, let clear the focus of before we remove it from
the fragment.
RelNote: "The keyboard will now close automatically when going from
a fragment with an open keyboard to a fragment with a recycler view."
Test: tested in sample app from bug
Bug: 196852211
Change-Id: I8b842dd9a421cfbc9189014b802f5e4b6b9c2a47
M fragment/fragment/src/main/java/androidx/fragment/app/SpecialEffectsController.java
rf...@gmail.com <rf...@gmail.com> #3
This has been fixed internally and will be available in the Fragment 1.4.0-beta01
release.
al...@android.com <al...@android.com> #4
The issue still persist in API version 27 and below in Fragment 1.4.0
rf...@gmail.com <rf...@gmail.com> #5
There is now way we are able to reproduce this issue. We are seeing these crashes in our Dev console and in Crashlytics console. Following are the observations that might be of help -
1. It seems linked only to ViewPager with fragments impementation
2. It started to produce with support library release 24.0.0 and still existing with 24.1.1
3. It's happening for devices right from Android Jellybean 4.2.2 to Android Marshmallow 6.x
Would be happy to provide any other additional information.
1. It seems linked only to ViewPager with fragments impementation
2. It started to produce with support library release 24.0.0 and still existing with 24.1.1
3. It's happening for devices right from Android Jellybean 4.2.2 to Android Marshmallow 6.x
Would be happy to provide any other additional information.
al...@android.com <al...@android.com> #6
Okay, thanks for the additional info.
rf...@gmail.com <rf...@gmail.com> #7
Any details with investigation? By when can a fix be expected?
nk...@gmail.com <nk...@gmail.com> #8
Please fix this asap...
ff...@gmail.com <ff...@gmail.com> #9
I have exactly this error. I have a Fragment with a FragmentStatePagerAdapter with child Fragments.
If you swipe the ViewPager really fast through some pages and then immediately press the back button, then you'll get this error.
If you swipe the ViewPager really fast through some pages and then immediately press the back button, then you'll get this error.
rf...@gmail.com <rf...@gmail.com> #12
Any updates anyone?
au...@google.com <au...@google.com> #13
I looked into the issue a little bit and it is caused by the changes to support library's FragmentManager that happened in 24.0.0. It is failing an assertion that should check if the call is running on the correct thread. adamp@ is looking into this. Are you having a lot of crashes due to this?
[Deleted User] <[Deleted User]> #14
Hello auri,
For the app i work, this crash happens a lot and is competing for the highest occurring crash daily.
It happens a few hundred times a day.
PS : You can see my earlier comments on the following thread, as i got merged fromhttps://code.google.com/p/android/issues/detail?id=216157
For the app i work, this crash happens a lot and is competing for the highest occurring crash daily.
It happens a few hundred times a day.
PS : You can see my earlier comments on the following thread, as i got merged from
rf...@gmail.com <rf...@gmail.com> #15
Yes, it's the major crash reason for our app too, 150-200 crashes daily reported.
br...@gmail.com <br...@gmail.com> #16
rf...@gmail.com <rf...@gmail.com> #17
Any further update on this? Has anybody been able to solve this?
nk...@gmail.com <nk...@gmail.com> #18
Please fix this issue we have seen massive amount of crashes.. google please make sure all the Viewpager issues are fixed.. never release something buggy
ag...@gmail.com <ag...@gmail.com> #19
It's also happening a lot here. Please guys, any updates about this?
[Deleted User] <[Deleted User]> #20
Seriously a little help will be deeply appreciated. This crashes a lot and has been impacting for a few months now.
Adress this or provide a direction to avoid it.
Adress this or provide a direction to avoid it.
rf...@gmail.com <rf...@gmail.com> #21
This issue seriously impacting the app ranking and performance. Google, please fix this asap.
he...@gmail.com <he...@gmail.com> #22
This works for me:
@Override
protected void onDestroy() {
Log.d(TAG, "onDestroy");
try {
super.onDestroy();
} catch (NullPointerException npe) {
Log.e(TAG, "NPE: Bug workaround");
}
@Override
protected void onDestroy() {
Log.d(TAG, "onDestroy");
try {
super.onDestroy();
} catch (NullPointerException npe) {
Log.e(TAG, "NPE: Bug workaround");
}
[Deleted User] <[Deleted User]> #23
catching the exception in Fragment or Activity ?
nk...@gmail.com <nk...@gmail.com> #24
Not sure why it's low priority bug... It's impacting hugley
ma...@gmail.com <ma...@gmail.com> #25
I'm seeing this in support-library 25.0.0 as well
[Deleted User] <[Deleted User]> #26
Same here
sa...@gmail.com <sa...@gmail.com> #27
I am seeing this as well and its completely blocking me. I am also using support-library 25.0.0.
In my experience FragmentStatePagerAdapter just does not support its dataset changing, for example items being deleted from within the pager which makes it quite hard to use.
Upgrading to support-library 25.0.0 fixed a number of occurrences of the crash mentioned in this issue. However i am still seeing the crash in the following case
(1) go to my activity with my ViewPager and view item1 (position=0), swipe to the next item which is item2 (position=1), delete item2, exit the activity
(2) go back into the activity with my ViewPager and view item1 (position=0), swipe to the next item, this time its item3 (position=1), delete item3, APP CRASHES with the log above
In step (2) if i swipe to any other item and delete it, the crash does not happen. Therefore it appears that its only deleting the position which was affected by delete in step (1) causes the crash. This however makes no sense as it should be a brand new instance of the activity/pager/fragments. But this reproduces consistently.
In my experience FragmentStatePagerAdapter just does not support its dataset changing, for example items being deleted from within the pager which makes it quite hard to use.
Upgrading to support-library 25.0.0 fixed a number of occurrences of the crash mentioned in this issue. However i am still seeing the crash in the following case
(1) go to my activity with my ViewPager and view item1 (position=0), swipe to the next item which is item2 (position=1), delete item2, exit the activity
(2) go back into the activity with my ViewPager and view item1 (position=0), swipe to the next item, this time its item3 (position=1), delete item3, APP CRASHES with the log above
In step (2) if i swipe to any other item and delete it, the crash does not happen. Therefore it appears that its only deleting the position which was affected by delete in step (1) causes the crash. This however makes no sense as it should be a brand new instance of the activity/pager/fragments. But this reproduces consistently.
nk...@gmail.com <nk...@gmail.com> #28
I've been waiting for the fix since few months and can't upgrade to 25
sa...@gmail.com <sa...@gmail.com> #29
I agree with nksa.. why is this "Priority-Small" it makes the FragmentStatePagerAdapter unusable for me.
mo...@android.com <mo...@android.com> #30
The example:
https://github.com/brain-murphy/supportFragmentManagerBug/tree/bug
uses setRetainInstance(true) on a fragment with UI. It has a click handler that points to the Activity. After orientation change, the activity has been destroyed and recreated, but the click handler still points to the old activity. The old Activity's fragment manager is no longer valid, so of course it fails.
I tried the sample with support library going back to 22.2.0 and it had the same issue.
uses setRetainInstance(true) on a fragment with UI. It has a click handler that points to the Activity. After orientation change, the activity has been destroyed and recreated, but the click handler still points to the old activity. The old Activity's fragment manager is no longer valid, so of course it fails.
I tried the sample with support library going back to 22.2.0 and it had the same issue.
au...@google.com <au...@google.com> #31
Can anyone attach another sample app that causes this crash?
mo...@android.com <mo...@android.com> #32
I attempted to reproduce using the instructions in https://code.google.com/p/android/issues/detail?id=216157 and am not able to get a crash.
Steps to reproduce:
- Create an AppCompatActivity that contains a fragment
- Fragment contains ViewPager + Tabs
- Each Fragment calls setRetainInstanceState(true)
- Assign a FragmentStatePagerAdapter to the ViewPager
- Run the app and rotate the screen, then switch tab
I used the simplest fragments (one text view). All fragments -- even the one with the view pager -- have setRetainInstance(true).
Steps to reproduce:
- Create an AppCompatActivity that contains a fragment
- Fragment contains ViewPager + Tabs
- Each Fragment calls setRetainInstanceState(true)
- Assign a FragmentStatePagerAdapter to the ViewPager
- Run the app and rotate the screen, then switch tab
I used the simplest fragments (one text view). All fragments -- even the one with the view pager -- have setRetainInstance(true).
he...@gmail.com <he...@gmail.com> #33
I get this error using a ViewPager inside a Fragment
Steps to reproduce:
- launch activity selecting the fragment with a ViewPager
- close the activity
- launch the same activity or another one hosting a ViewPager
Steps to reproduce:
- launch activity selecting the fragment with a ViewPager
- close the activity
- launch the same activity or another one hosting a ViewPager
sa...@gmail.com <sa...@gmail.com> #34
I'm trying to put together a test app showing my error case. I'm having trouble getting my dependencies working. When i have a test app i will post here.
sa...@gmail.com <sa...@gmail.com> #35
To workaround this issue i have an Adapter which extends FragementStatePagerAdapter and I overwrite "finishUpdate" as follows
@Override
public void finishUpdate(ViewGroup container) {
try{
super.finishUpdate(container);
} catch (NullPointerException npe){
System.out.println("Ignore the NPE in FragmentStatePagerAdapter.finishUpdate");
}
}
@Override
public void finishUpdate(ViewGroup container) {
try{
super.finishUpdate(container);
} catch (NullPointerException npe){
System.out.println("Ignore the NPE in FragmentStatePagerAdapter.finishUpdate");
}
}
ge...@gmail.com <ge...@gmail.com> #36
Same here,
I am using support-v4:25.1.0
the error happened in myFragment which has a Viewpager and myFragmentStatePagerAdapter classes, the adapter overrides `finishUpdate`
and the error happened when executing `commitNowAllowingStateLoss`
I myself couldn't reproduce the error as I found it on Fabric, and the user phone is Redmi Note 3, which looks like a Chinese phone with a custom ROM.
attached the log.
I am using support-v4:25.1.0
the error happened in myFragment which has a Viewpager and myFragmentStatePagerAdapter classes, the adapter overrides `finishUpdate`
and the error happened when executing `commitNowAllowingStateLoss`
I myself couldn't reproduce the error as I found it on Fabric, and the user phone is Redmi Note 3, which looks like a Chinese phone with a custom ROM.
attached the log.
ge...@gmail.com <ge...@gmail.com> #37
Adding more to my #37 comment.
I found that the user faced this problem only when opening the activity from a notification, the main activity is in singleTask mode, and here is the code I am using to start the activity.
Intent i = new Intent(MyApplication.getInstance(), MainActivity.class);
Bundle bundle = new Bundle();
bundle.putString(Constants.BundleKeyConstant.NEWS_CATEGORY, "trending");
bundle.putString(Constants.BundleKeyConstant.TOPIC_ID, topicId);
bundle.putLong(Constants.BundleKeyConstant.L_DATE, data.optLong("lDate", 0));
i.putExtras(bundle);
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
MyApplication.getInstance().startActivity(i);
I found that the user faced this problem only when opening the activity from a notification, the main activity is in singleTask mode, and here is the code I am using to start the activity.
Intent i = new Intent(MyApplication.getInstance(), MainActivity.class);
Bundle bundle = new Bundle();
bundle.putString(Constants.BundleKeyConstant.NEWS_CATEGORY, "trending");
bundle.putString(Constants.BundleKeyConstant.TOPIC_ID, topicId);
bundle.putLong(Constants.BundleKeyConstant.L_DATE, data.optLong("lDate", 0));
i.putExtras(bundle);
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
MyApplication.getInstance().startActivity(i);
[Deleted User] <[Deleted User]> #38
Im facing this issue, has it been fixed?.
It should have high priority!
It should have high priority!
[Deleted User] <[Deleted User]> #39
Issue still isn't fixed.
be...@gmail.com <be...@gmail.com> #40
I was able to reproduce the issue. It always happens when same instance of ViewPager gets reused by different instances of the same fragment. Import and launch the attached demo project. Switch from the Home tab to the Dashboard tab and then, when switching back to the Home tab, you will see the exception.
The reason for this exception if that the ViewPager instances from the previous instance of HomeFragment gets reused and still has old adapter set. When new instance of adapter is assigned, framework tries to destroy old adapter's sub-fragments but fails.
To work around the issue it's enough to null the adapter (see HomeFragment.onDestroyView() method) when the fragment destroys the view.
Hope this helps to fix the NPE with the upcoming support library updates.
The reason for this exception if that the ViewPager instances from the previous instance of HomeFragment gets reused and still has old adapter set. When new instance of adapter is assigned, framework tries to destroy old adapter's sub-fragments but fails.
To work around the issue it's enough to null the adapter (see HomeFragment.onDestroyView() method) when the fragment destroys the view.
Hope this helps to fix the NPE with the upcoming support library updates.
mo...@gmail.com <mo...@gmail.com> #41
This sounds like the exact issue I am getting in my project.
I have an Activity, and within this a Fragment (Fragment A). This fragment contains a ViewPager, which has a FragmentPageAdapter for a few other Fragments.
However when switching from Fragment A to a new Fragment B within the Activity I get weird NPE's on the pages of the ViewPager which aren't visible.
I have tried nulling the FragmentPageAdapter instance on Fragment A, when onDestroyView is called. But this doesn't help.
A funny thing is, on startup of the app, if I immediately switch from Fragment A to B, I get the error. If i wait a few seconds then switch to Fragment B, I don't get the error.
Any direction and advice will be welcomed.
I have an Activity, and within this a Fragment (Fragment A). This fragment contains a ViewPager, which has a FragmentPageAdapter for a few other Fragments.
However when switching from Fragment A to a new Fragment B within the Activity I get weird NPE's on the pages of the ViewPager which aren't visible.
I have tried nulling the FragmentPageAdapter instance on Fragment A, when onDestroyView is called. But this doesn't help.
A funny thing is, on startup of the app, if I immediately switch from Fragment A to B, I get the error. If i wait a few seconds then switch to Fragment B, I don't get the error.
Any direction and advice will be welcomed.
mo...@gmail.com <mo...@gmail.com> #42
As an additional comment:
I get the weird error with this:
mPagerAdapter = new MyPagerAdapter(getChildFragmentManager(), this);
But not with this, however my Fragment views arent then drawing (so another different issue):
mPagerAdapter = new MyPagerAdapter(getActivity().getSupportFragmentManager(), this);
I get the weird error with this:
mPagerAdapter = new MyPagerAdapter(getChildFragmentManager(), this);
But not with this, however my Fragment views arent then drawing (so another different issue):
mPagerAdapter = new MyPagerAdapter(getActivity().getSupportFragmentManager(), this);
ni...@google.com <ni...@google.com> #43
Closing this issue due to modification date out of supported range.
If this issue is still relevant for the latest Jetpack (androidx.*
) libraries and important to address, please file a new issue and it will enter our revamped issue triage process.
Description
Following is the Logcat:
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.Handler android.support.v4.app.FragmentHostCallback.getHandler()' on a null object reference
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1623)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:637)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1237)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1085)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1611)
at android.view.View.measure(View.java:18926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5908)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:671)
at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:90)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1319)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:736)
at android.view.View.measure(View.java:18926)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
at android.view.View.measure(View.java:18926)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
at android.view.View.measure(View.java:18926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5908)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:18926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5908)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:721)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:612)
at android.view.View.measure(View.java:18926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5908)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.view.View.measure(View.java:18926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5908)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:721)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:612)
at android.view.View.measure(View.java:18926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5908)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:3076)
at android.view.View.measure(View.java:18926)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2411)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1429)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1677)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1314)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7057)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:829)
at android.view.Choreographer.doCallbacks(Choreographer.java:606)
at android.view.Choreographer.doFrame(Choreographer.java:576)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:815)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6917)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
I am getting this bug on my console since last few library updates, but ill now i didn't got any direction. Can you please look into this and let me know what could be possible solution for this.
Thanks