Skip to content

[Bug]: Crash when trying to upload via image selector on first use #6131

Closed
@sivaraam

Description

@sivaraam

Summary

The app crashes when trying to do an upload using the normal file picker for the first after installation. This happens on the latest main. The second upload seems to correctly take us to the upload screen, though. We should look into fixing this as it is not a good UX to crash upon first upload.

Steps to reproduce

  1. Install the app afresh
  2. Login and try to upload using the normal photo picker
  3. Note the "Access to media" permission request shown
  4. Grant the access
  5. Observe the crash

Expected behaviour

The app should proceed to the upload screen after the permission has been granted.

Actual behaviour

The app crashes with the crash log given below.

Device name

OnePlus Nord

Android version

Android 12

Commons app version

main (does not happen in v5.1.1)

Device logs

android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:9812)
at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:1942)
at android.view.ViewGroup.invalidateChild(ViewGroup.java:6233)
at android.view.View.invalidateInternal(View.java:18933)
at android.view.View.invalidate(View.java:18889)
at android.view.View.setFlags(View.java:16458)
at android.view.View.setVisibility(View.java:11971)
at fr.free.nrw.commons.upload.UploadActivity.checkStoragePermissions$lambda$7(UploadActivity.kt:302)
at fr.free.nrw.commons.upload.UploadActivity.$r8$lambda$jLDR9mwKVU8obZI0s8ZliP6txEE(Unknown Source:0)
at fr.free.nrw.commons.upload.UploadActivity$$ExternalSyntheticLambda4.run(D8$$SyntheticClass:0)
at java.lang.Thread.run(Thread.java:1012)

Screen-shots

Screen recording to demonstrate the issue

Would you like to work on the issue?

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions