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

App crashing on clicking any search result in Explore #2123

Closed
ShridharGoel opened this issue Dec 15, 2018 · 5 comments · Fixed by #2138
Closed

App crashing on clicking any search result in Explore #2123

ShridharGoel opened this issue Dec 15, 2018 · 5 comments · Fixed by #2138

Comments

@ShridharGoel
Copy link
Contributor

ShridharGoel commented Dec 15, 2018

Summary:

App crashes on clicking any search result in Explore.

Steps to reproduce:

  1. Search something in Explore.
  2. Click on any search result.
  3. The app will crash.

System logs:

java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.FragmentActivity android.support.v4.app.Fragment.getActivity()' on a null object reference at fr.free.nrw.commons.media.MediaDetailPagerFragment$MediaDetailAdapter.getItem(MediaDetailPagerFragment.java:401) at android.support.v4.app.FragmentStatePagerAdapter.instantiateItem(FragmentStatePagerAdapter.java:109)
        at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:1004)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1152)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1086)
        at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1616)
        at android.view.View.measure(View.java:19883)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6085)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
        at android.view.View.measure(View.java:19883)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6085)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
        at android.view.View.measure(View.java:19883)
        at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
        at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
        at android.view.View.measure(View.java:19883)
        at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1059)
        at android.view.View.measure(View.java:19883)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6085)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
        at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:141)
        at android.view.View.measure(View.java:19883)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6085)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
        at android.view.View.measure(View.java:19883)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6085)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
        at android.view.View.measure(View.java:19883)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6085)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
        at android.view.View.measure(View.java:19883)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6085)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
        at com.android.internal.policy.DecorView.onMeasure(DecorView.java:693)
        at android.view.View.measure(View.java:19883)
        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2317)
        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1408)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1661)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1296)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6401)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:876)
        at android.view.Choreographer.doCallbacks(Choreographer.java:688)
        at android.view.Choreographer.doFrame(Choreographer.java:623)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:862)
        at android.os.Handler.handleCallback(Handler.java:754)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:163)
        at android.app.ActivityThread.main(ActivityThread.java:6205)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)

Commons app version:
`
2.9.0
Branch: master
Build: betaDebug

GIF:

ezgif com-video-to-gif 2

Would you like to work on the issue?

Yes

@domdomegg
Copy link
Member

12-17 00:24:54.919 19372-19372/fr.free.nrw.commons E/ACRA: ACRA caught a NullPointerException for fr.free.nrw.commons
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.FragmentActivity android.support.v4.app.Fragment.getActivity()' on a null object reference
        at fr.free.nrw.commons.media.MediaDetailPagerFragment$MediaDetailAdapter.getItem(MediaDetailPagerFragment.java:401)
        at android.support.v4.app.FragmentStatePagerAdapter.instantiateItem(FragmentStatePagerAdapter.java:109)
        at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:1004)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1152)
        at android.support.v4.view.ViewPager.populate(ViewPager.java:1086)
        at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1616)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.view.View.measure(View.java:18788)
        at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
        at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
        at android.view.View.measure(View.java:18788)
        at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1059)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:141)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5951)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
        at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
        at android.view.View.measure(View.java:18788)
        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2100)
        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1452)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
        at android.view.Choreographer.doCallbacks(Choreographer.java:670)
        at android.view.Choreographer.doFrame(Choreographer.java:606)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.ja

@domdomegg
Copy link
Member

@domdomegg
Copy link
Member

Removing getParentFragment(). does fix it. I'm not sure why it is used here given getActivity() should already go up the chain until it reaches the calling activity or returns null.

Have submitted #2138 but want @neslihanturan to look over as worried I'm missing something. Also might be other places where similar stuff has been done which would be worth fixing.

@maskaravivek
Copy link
Member

@domdomegg Can you check whether clicking contributions are affected?

@neslihanturan
Copy link
Collaborator

I wanted to see a detailed NPE, to understand if parent fragment or activity is null. I thought this could guide us better to understand possible future crash reports. But if it is problematic, we can always use get activity. I am not a big fan of it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants