wordpress-mobile / AztecEditor-Android

A reusable native Android rich text editor component.
Mozilla Public License 2.0
675 stars 112 forks source link

Crash report 7.8: IllegalArgumentException, Kotlin not playing nice with Java? #456

Closed tonyr59h closed 6 years ago

tonyr59h commented 6 years ago
Fatal Exception: org.greenrobot.eventbus.EventBusException: Invoking subscriber failed
       at org.greenrobot.eventbus.EventBus.handleSubscriberException(EventBus.java:505)
       at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:487)
       at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:479)
       at org.greenrobot.eventbus.HandlerPoster.handleMessage(HandlerPoster.java:67)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:5529)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
Caused by 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:735)
       at org.wordpress.android.ui.posts.EditPostActivity.onUploadSuccess(EditPostActivity.java:792)
       at org.wordpress.android.ui.posts.EditPostActivity.onMediaUploaded(EditPostActivity.java:2415)
       at java.lang.reflect.Method.invoke(Method.java)
       at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:485)
       at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:479)
       at org.greenrobot.eventbus.HandlerPoster.handleMessage(HandlerPoster.java:67)
mzorz commented 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

maxme commented 6 years ago

@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)

maxme commented 6 years ago

Note: this happens in wpandroid 8.1 (with async) due to a null remoteUrl here

maxme commented 6 years ago

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

mzorz commented 6 years ago

Closing via https://github.com/wordpress-mobile/WordPress-Android/pull/6626

maxme commented 6 years ago

Re-opening, apparently this still happens in recent versions of wpandroid (8.7 for example) but there are less frequent than before the patch.

maxme commented 6 years ago

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)
     ...
mzorz commented 6 years ago

re-closing via https://github.com/wordpress-mobile/WordPress-Android/pull/6891