NPE on View object when sharing image with contact
- [x] I have searched open and closed issues for duplicates
- [x] I am submitting a bug report for existing functionality that does not work as intended
- [x] I have read https://github.com/signalapp/Signal-Android/wiki/Submitting-useful-bug-reports
- [x] This isn't a feature request or a discussion topic
Bug description
I encountered a crash when attempting to share an image with a contact via Signal. This was caused by an NPE in ViewUtil.animateIn(). From the debug log, it seems as though the ContactSelectionListFragment object returned a null View object.
10-03 17:38:30.155 24104 24104 E AndroidRuntime: at org.thoughtcrime.securesms.ShareActivity.handleResolvedMedia(ShareActivity.java:236)
10-03 17:38:30.155 24104 24104 E AndroidRuntime: at org.thoughtcrime.securesms.ShareActivity.access$400(ShareActivity.java:65)
10-03 17:38:30.155 24104 24104 E AndroidRuntime: at org.thoughtcrime.securesms.ShareActivity$ResolveMediaTask.onPostExecute(ShareActivity.java:344)
Debug log snippet above shows that the line of code passing the null reference is in ShareActivity:
236 ViewUtil.fadeIn(contactsFragment.getView(), 300);
There is no null check on the View being returned here.
Steps to reproduce
NOTE: I cannot reproduce this behavior. I will still include the steps I took leading up to the initial crash.
- Open Google's "Photos" application
- Choose an image to share and share to a Signal contact
- Observe "Signal has crashed!"
Actual result: Signal crashes. Expected result: Signal should share the image to the chosen contact
Screenshots
Device info
Device: Nexus 6 Android version: 7.1.1 Signal version: 4.28.0
Link to debug log
https://debuglogs.org/c48af2b032a0ffba168a0f2dcc2be2defdbd26c1be3af1bc4f92a328133525ef
I'd love to contribute to this project. What should we do if the view is null? Clearly we can't perform the actions on the view that would otherwise run.
@jeffmcnd I think the most useful information you could provide is research.
- Why does this crash happen?
- Is there an easy way to reproduce the crash?
- Suggestions for solutions
Given that a fragment is returning a null view, my guess is that either the fragment wasn't properly initialized or that we're calling the parent function when we shouldn't (i.e. after the fragment has been disposed).
@jeffmcnd it's worth noting that I remember trying repeatedly to reproduce this after the first few times I saw it and was unable to. I believe my initial thoughts there was it was something weird happening when Android sent Signal information about the thumbnail, or something. I'm not really an Android guy :)
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
@greyson-signal @junitas
I think the offending piece of code no longer exists in the main branch. Most of the references to contactsFragment are wrapped in null checks now except for lines 415, 428, and 463 of app/src/main/java/org/thoughtcrime/securesms/sharing/ShareActivity.java.
Can this ticket be closed now?