Apps-android-commons: Crash when scrolling down my contributions

Created on 16 Nov 2020  Â·  18Comments  Â·  Source: commons-app/apps-android-commons

Latest master 2ed5a74

11-16 07:58:29.607 15666 15666 D ViewRootImpl@de9072a[MainActivity]: ViewPostIme pointer 1
11-16 07:58:45.923  5635  5804 I clp-JNI : Add pinfo.  (channel) b15b7b1 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity (server) (pkg) AppWindowToken{21bd8c5 token=Token{dce033c ActivityRecord{a13012f u0 fr.free.nrw.commons/.contributions.MainActivity t16652}}} 15666 10383 (action) 0
11-16 07:58:45.927 15666 15666 D ViewRootImpl@de9072a[MainActivity]: ViewPostIme key 0
11-16 07:58:45.968  5635  5804 I clp-JNI : Add pinfo.  (channel) b15b7b1 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity (server) (pkg) AppWindowToken{21bd8c5 token=Token{dce033c ActivityRecord{a13012f u0 fr.free.nrw.commons/.contributions.MainActivity t16652}}} 15666 10383 (action) 1
11-16 07:58:45.969 15666 15666 D ViewRootImpl@de9072a[MainActivity]: ViewPostIme key 1
11-16 07:58:45.969 15666 22165 V OkHttp  : --> GET https://raw.githubusercontent.com/commons-app/campaigns/master/campaigns.json
11-16 07:58:45.971 15666 22165 V OkHttp  : <-- 200 OK https://raw.githubusercontent.com/commons-app/campaigns/master/campaigns.json (1ms, unknown-length body)
11-16 07:58:45.973 15666 15666 D ScrollView:  onsize change changed 
11-16 07:58:45.973 15666 15666 D ScrollView:  onsize change changed 
11-16 07:58:45.989 15666 22173 D OkHttp  : --> GET https://commons.wikimedia.org/w/api.php?format=json&formatversion=2&errorformat=plaintext&action=query&meta=notifications&notformat=model&notlimit=max&notwikis=wikidatawiki%7Ccommonswiki%7Cenwiki&notfilter=%21read
11-16 07:58:45.990 15666 22173 D CookieManager: Domain:commons.wikimedia.org
11-16 07:58:46.018 15666 22082 D OkHttp  : --> GET https://commons.wikimedia.org/w/api.php?action=query&format=json&formatversion=2&generator=allimages&gaisort=timestamp&gaidir=older&prop=imageinfo&iiprop=url|extmetadata&iiurlwidth=640&iiextmetadatafilter=DateTime|Categories|GPSLatitude|GPSLongitude|ImageDescription|DateTimeOriginal|Artist|LicenseShortName|LicenseUrl&gaiuser=Syced&gailimit=10&gaicontinue=20201024151506|Nandi_bear_1961_(cropped).png&continue=gaicontinue||
11-16 07:58:46.018 15666 22082 D CookieManager: Domain:commons.wikimedia.org
11-16 07:58:46.525 15666 22173 D OkHttp  : <-- 200 https://commons.wikimedia.org/w/api.php?format=json&formatversion=2&errorformat=plaintext&action=query&meta=notifications&notformat=model&notlimit=max&notwikis=wikidatawiki%7Ccommonswiki%7Cenwiki&notfilter=%21read (534ms, unknown-length body)
11-16 07:58:46.526 15666 15666 D ContributionsFragment: Number of notifications is 0
11-16 07:58:47.439  5635  5804 I clp-JNI : Add pinfo.  (channel) b15b7b1 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity (server) (pkg) AppWindowToken{21bd8c5 token=Token{dce033c ActivityRecord{a13012f u0 fr.free.nrw.commons/.contributions.MainActivity t16652}}} 15666 10383 (action) 0
11-16 07:58:47.440 15666 15666 D ViewRootImpl@de9072a[MainActivity]: ViewPostIme pointer 0
11-16 07:58:47.486 15666 15666 W StaticLayout: maxLineHeight should not be -1.  maxLines:2 lineCount:2
11-16 07:58:47.486 15666 15666 W StaticLayout: maxLineHeight should not be -1.  maxLines:2 lineCount:2
11-16 07:58:47.512  5635  5804 I clp-JNI : Add pinfo.  (channel) b15b7b1 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity (server) (pkg) AppWindowToken{21bd8c5 token=Token{dce033c ActivityRecord{a13012f u0 fr.free.nrw.commons/.contributions.MainActivity t16652}}} 15666 10383 (action) 1
11-16 07:58:47.513 15666 15666 D ViewRootImpl@de9072a[MainActivity]: ViewPostIme pointer 1
11-16 07:58:47.531 15666 17503 I         : Increase max job count 60
11-16 07:58:48.582 15666 22082 D OkHttp  : <-- 200 https://commons.wikimedia.org/w/api.php?action=query&format=json&formatversion=2&generator=allimages&gaisort=timestamp&gaidir=older&prop=imageinfo&iiprop=url|extmetadata&iiurlwidth=640&iiextmetadatafilter=DateTime|Categories|GPSLatitude|GPSLongitude|ImageDescription|DateTimeOriginal|Artist|LicenseShortName|LicenseUrl&gaiuser=Syced&gailimit=10&gaicontinue=20201024151506|Nandi_bear_1961_(cropped).png&continue=gaicontinue|| (2564ms, unknown-length body)
11-16 07:58:48.584 15666 22082 D OkHttp  : --> GET https://commons.wikimedia.org/w/api.php?format=json&action=wbgetentities&props=labels&languagefallback=1&ids=M95178133%7CM95178483%7CM95186315%7CM95187080%7CM95190808%7CM95206194%7CM95223029%7CM95272930%7CM95288857%7CM95410471
11-16 07:58:48.585 15666 22082 D CookieManager: Domain:commons.wikimedia.org
11-16 07:58:48.681  5635  5804 I clp-JNI : Add pinfo.  (channel) b15b7b1 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity (server) (pkg) AppWindowToken{21bd8c5 token=Token{dce033c ActivityRecord{a13012f u0 fr.free.nrw.commons/.contributions.MainActivity t16652}}} 15666 10383 (action) 0
11-16 07:58:48.682 15666 15666 D ViewRootImpl@de9072a[MainActivity]: ViewPostIme pointer 0
11-16 07:58:48.748  5635  5804 I clp-JNI : Add pinfo.  (channel) b15b7b1 fr.free.nrw.commons/fr.free.nrw.commons.contributions.MainActivity (server) (pkg) AppWindowToken{21bd8c5 token=Token{dce033c ActivityRecord{a13012f u0 fr.free.nrw.commons/.contributions.MainActivity t16652}}} 15666 10383 (action) 1
11-16 07:58:48.749 15666 15666 D ViewRootImpl@de9072a[MainActivity]: ViewPostIme pointer 1
11-16 07:58:49.105 15666 22169 D OkHttp  : --> GET https://en.wikipedia.org/api/rest_v1/page/media-list/Takahan_Ryokan
11-16 07:58:49.106 15666 22169 D CookieManager: Domain:en.wikipedia.org
11-16 07:58:49.106 15666 22169 D CookieManager: Adding centralauth cookies
11-16 07:58:49.227 15666 22169 D OkHttp  : <-- 200 https://en.wikipedia.org/api/rest_v1/page/media-list/Takahan_Ryokan (122ms, 80-byte body)
11-16 07:58:49.295 15666 22082 D OkHttp  : <-- 200 https://commons.wikimedia.org/w/api.php?format=json&action=wbgetentities&props=labels&languagefallback=1&ids=M95178133%7CM95178483%7CM95186315%7CM95187080%7CM95190808%7CM95206194%7CM95223029%7CM95272930%7CM95288857%7CM95410471 (710ms, unknown-length body)
11-16 07:58:49.363 15666 15666 D AndroidRuntime: Shutting down VM
11-16 07:58:49.365 15666 15666 E AndroidRuntime: FATAL EXCEPTION: main
11-16 07:58:49.365 15666 15666 E AndroidRuntime: Process: fr.free.nrw.commons, PID: 15666
11-16 07:58:49.365 15666 15666 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'fr.free.nrw.commons.Media fr.free.nrw.commons.contributions.Contribution.getMedia()' on a null object reference
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at fr.free.nrw.commons.contributions.ContributionViewHolder.init(ContributionViewHolder.java:70)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at fr.free.nrw.commons.contributions.ContributionsListAdapter.onBindViewHolder(ContributionsListAdapter.java:49)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at fr.free.nrw.commons.contributions.ContributionsListAdapter.onBindViewHolder(ContributionsListAdapter.java:14)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7093)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7172)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6037)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6304)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6143)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6139)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2314)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:560)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1591)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:668)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4141)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3853)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4410)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.View.layout(View.java:22420)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewGroup.layout(ViewGroup.java:6579)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.View.layout(View.java:22420)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewGroup.layout(ViewGroup.java:6579)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.View.layout(View.java:22420)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewGroup.layout(ViewGroup.java:6579)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.View.layout(View.java:22420)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewGroup.layout(ViewGroup.java:6579)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.View.layout(View.java:22420)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewGroup.layout(ViewGroup.java:6579)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.View.layout(View.java:22420)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewGroup.layout(ViewGroup.java:6579)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.View.layout(View.java:22420)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewGroup.layout(ViewGroup.java:6579)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.View.layout(View.java:22420)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewGroup.layout(ViewGroup.java:6579)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.View.layout(View.java:22420)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewGroup.layout(ViewGroup.java:6579)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.View.layout(View.java:22420)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewGroup.layout(ViewGroup.java:6579)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.View.layout(View.java:22420)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewGroup.layout(ViewGroup.java:6579)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at com.android.internal.policy.DecorView.onLayout(DecorView.java:1041)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.View.layout(View.java:22420)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewGroup.layout(ViewGroup.java:6579)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:3343)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2807)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1853)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8476)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.Choreographer.doCallbacks(Choreographer.java:761)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.Choreographer.doFrame(Choreographer.java:696)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:873)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:214)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:7032)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
11-16 07:58:49.365 15666 15666 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)

Not sure if that matters, but some context: I used Nearby to upload a picture of both items Takahan Ryokan and Nakatani Foundation.

assigned bug gallery

All 18 comments

@nicolas-raoul Can I work on this issue?

Sure, thanks! 🙂

On Tue, 17 Nov 2020, 04:36 gouri-panda, notifications@github.com wrote:

@nicolas-raoul https://github.com/nicolas-raoul Can I work on this
issue?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/commons-app/apps-android-commons/issues/4038#issuecomment-728279048,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAYKBQFPSTFBH33NW2V7UTSQF5LBANCNFSM4TWPQSWQ
.

Hi, I have been able to reproduce this issue too, seems like this happens while some upload is going on and since we use the the pagedListAdapter, whose getItem function is @Nullable we need to handle the case when the item returned is null, this could happen when the differ is still processing the item, @gouri-panda , you might want to handle this in the adapter itself instead of the ViewHolder

@ashishkumar0207 What should we add to the default value in PageListAdapter?

There should not be any default value, I am not very much aware of the api but for now I guess just handling the NPE in the adapter should be fine

@ashishkumar0207 I'm still confused how do we handle this situation? Thanks!

 @Nullable
        @Override
        protected Contribution getItem(int position) {
            try {
                if (super.getItem(position) != null) {
                    return super.getItem(position);
                }
            }catch (Exception e){
                e.printStackTrace();
            }
          // What should we do return here?
        }

Hi @gouri-panda, I meant in the ContributionListAdapter#onBindViewHolder, basically not to call holder.init ()when there are chances of getItem being null. Not the best solution but should work for now.

Note: This also happens while not uploading, even after restarting the phone and before starting any upload. I just sent a crash log with the name "scrolling down".

Probably in that case catching the exception might not work. I came across something, https://github.com/airbnb/epoxy/issues/585, @gouri-panda, this might help. Also can you confirm, if hasStableIdss(true) is enabled for this recycler view

@ashishkumar468 apologies for the delay. I think also the root cause was duplicate IDs among list items.

if hasStableIdss(true) is enabled for this recycler view

It's false in ContributionsListAdapter
@ashishkumar468 @nicolas-raoul What should I do?

Hi @gouri-panda, No problem, yes can you try calling setStableIds(true) for the adapter and see if this solves the issue?

yes can you try calling setStableIds(true) for the adapter and see if this solves the issue?

@ashishkumar468 we can't use adapter.setHasStableIds(true) with ObservableArrayList/ObservableFields.
Can we do this in ContributionListFragment ?

if (!adapter.hasObservers()) {
    adapter.setHasStableIds(true)
}

I think it's pointless. What do you think?

Is this still open?
Help me reproduce this issue, I'm somehow not getting it.
@nicolas-raoul @ashishkumar0207
Thx.

@4D17Y4 Yes it is an unassigned bug :-)

The first task would be to understand how to reproduce the issue.

It now fails on a different picture:

12-23 08:33:12.605 21629 22305 D OkHttp  : --> GET https://commons.wikimedia.org/w/api.php?format=json&action=wbgetentities&props=labels&languagefallback=1&ids=M92420394%7CM92420413%7CM92522277%7CM92557062%7CM92557119%7CM92785874%7CM92824806%7CM92824807%7CM92824812%7CM92824813
12-23 08:33:12.606 21629 22305 D CookieManager: Domain:commons.wikimedia.org
12-23 08:33:12.822 21629 22118 D OkHttp  : <-- 200 https://commons.wikimedia.org/w/api.php?format=json&action=wbgetentities&props=labels&languagefallback=1&ids=M92420394%7CM92420413%7CM92522277%7CM92557062%7CM92557119%7CM92785874%7CM92824806%7CM92824807%7CM92824812%7CM92824813 (783ms, unknown-length body)
12-23 08:33:12.865 21629 21629 E InputEventReceiver: Exception dispatching input event.
12-23 08:33:12.865 21629 21629 D AndroidRuntime: Shutting down VM
12-23 08:33:12.866 21629 21629 E AndroidRuntime: FATAL EXCEPTION: main
12-23 08:33:12.866 21629 21629 E AndroidRuntime: Process: fr.free.nrw.commons, PID: 21629
12-23 08:33:12.866 21629 21629 E AndroidRuntime: java.lang.NullPointerException: Attempt to invoke virtual method 'fr.free.nrw.commons.Media fr.free.nrw.commons.contributions.Contribution.getMedia()' on a null object reference
12-23 08:33:12.866 21629 21629 E AndroidRuntime:    at fr.free.nrw.commons.contributions.ContributionViewHolder.init(ContributionViewHolder.java:69)
12-23 08:33:12.866 21629 21629 E AndroidRuntime:    at fr.free.nrw.commons.contributions.ContributionsListAdapter.onBindViewHolder(ContributionsListAdapter.java:49)
12-23 08:33:12.866 21629 21629 E AndroidRuntime:    at fr.free.nrw.commons.contributions.ContributionsListAdapter.onBindViewHolder(ContributionsListAdapter.java:14)
12-23 08:33:12.866 21629 21629 E AndroidRuntime:    at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7093)

The crash happens when this picture starts showing a bit on the screen: https://commons.wikimedia.org/wiki/File:%E3%82%88%E3%81%86%E3%81%8B%E3%82%93%E3%81%AE%E9%96%8B%E3%81%91%E6%96%B9_3.jpg

This picture is the 24th is my uploads, 25th if counting 1 failed upload.

After resetting the app's data (which removed my failed upload), the crash happens a bit further, at the 26th picture.

After uploading 10 new pictures, the crash happens for a more recent picture, which happens to now be the 26th picture.

To reproduce, could you please try to upload at least 30 pictures? You can freely use these pictures: https://drive.google.com/drive/u/1/folders/1T5wfM16qb78XCvnf1Zunww4neg8BXJj6
Thanks!

Hey @nicolas-raoul,
It does happen with me, but just to confirm this happens when u scroll too fast and after you restart the app right?

There should not be any default value, I am not very much aware of the api but for now I guess just handling the NPE in the adapter should be fine

I think the same,
updating the condition to check for NPE.

As for the investigation, I got to know that the function is called with a position as 0 and it gets contribution as null making it crash.

basically not to call holder.init () when there are chances of getItem being null. Not the best solution but should work for now.

I was thinking of adding the condition in the holder.init() instead, as it would be better cuz then we can directly access the contribution, but here we have to access the method twice or have to initialize a parameter.

Any reasons we should be calling it in onBindViewHolder()? @ashishkumar0207

Thx

It happens to me:

  • even when scrolling very slowly
  • even after using the app for hours and using other activities such as Nearby and Explore

Reopenning since the root cause is still unsolved.

Was this page helpful?
0 / 5 - 0 ratings