Closed tonyr59h closed 6 years ago
I’ve been investigating this a bit - the only reason I could think of having an empty url there is that the actual mediamodel
didn’t have one in the first place. i.e. one case I think could be MediaUtils.getPath()
in MediaUtils.getRealPathFromURI
in EditPostActivity.buildMediaModel()
might return null if the content descriptor is unknown ( as per util/MediaUtils.getDocumentProviderPathKitkatOrHigher()
).
Particularly, it seems MediaUtils.getRealPathFromURI
is what should be used in PostUploadService.uploadImage()
instead of replicating the code there, and a probable cause for the mediamodel to have a null path when the file is uploaded.
Worth noting, this is all going to change now that the async-media
work is merged into develop
, so I guess it's probably better to wait for that, or maybe patch this particular NPE in the case many users are affected
@mzorz now that async is merged, can you check this is still an issue? (I guess the error was coming from a null mediaUrl
here)
Note: this happens in wpandroid 8.1 (with async) due to a null remoteUrl
here
In the hybrid editor this doesn't crash but we set a null URL in the HTML doc: https://github.com/wordpress-mobile/WordPress-Android/blob/3bcbed86225a133237adf1f7362a2e162a9f77a5/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/EditorFragment.java#L1135-L1136
Re-opening, apparently this still happens in recent versions of wpandroid (8.7 for example) but there are less frequent than before the patch.
Stack trace is actually a bit different, this happens only in EditPostActivity.onMediaUploadCancelClicked
:
Fatal Exception: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter value
at org.wordpress.aztec.AztecAttributes.setValue(AztecAttributes.kt)
at org.wordpress.android.editor.AztecEditorFragment.onMediaUploadSucceeded(AztecEditorFragment.java:902)
at org.wordpress.android.ui.posts.EditPostActivity.onMediaRetryClicked(EditPostActivity.java:2476)
at org.wordpress.android.editor.AztecEditorFragment.onMediaTapped(AztecEditorFragment.java:1325)
...