wordpress-mobile / WordPress-Android

WordPress for Android
http://android.wordpress.org
GNU General Public License v2.0
2.99k stars 1.32k forks source link

NullPointerException: mediaFile.mediaId must not be null #13650

Closed mzorz closed 3 years ago

mzorz commented 3 years ago

Sentry Url: https://sentry.io/share/issue/f6c19e5b31b543adacf3f80c6b319fa2/ Possible dupe: https://sentry.io/share/issue/55717409b678402d9825737efd7536d2/

java.lang.NullPointerException: mediaFile.mediaId must not be null
    at org.wordpress.android.ui.stories.SaveStoryGutenbergBlockUseCase$replaceLocalMediaIdsWithRemoteMediaIdsInPost$1.doWithMediaFilesJson(SaveStoryGutenbergBlockUseCase.kt:131)
    at org.wordpress.android.ui.stories.SaveStoryGutenbergBlockUseCase.findAllStoryBlocksInPostAndPerformOnEachMediaFilesJson(SaveStoryGutenbergBlockUseCase.kt:108)
    at org.wordpress.android.ui.stories.SaveStoryGutenbergBlockUseCase.replaceLocalMediaIdsWithRemoteMediaIdsInPost(SaveStoryGutenbergBlockUseCase.kt:118)
    at org.wordpress.android.ui.uploads.MediaUploadReadyProcessor.replaceMediaFileWithUrlInPost(MediaUploadReadyProcessor.java:33)
    at org.wordpress.android.ui.uploads.UploadService.updatePostWithMediaUrl(UploadService.java:626)
    at org.wordpress.android.ui.uploads.UploadService.updatePostWithCurrentlyCompletedUploads(UploadService.java:474)
    at org.wordpress.android.ui.uploads.UploadService.updateOnePostModelWithCompletedAndFailedUploads(UploadService.java:722)
    at org.wordpress.android.ui.uploads.UploadService.doFinalProcessingOfPosts(UploadService.java:1008)
    at org.wordpress.android.ui.uploads.UploadService.stopServiceIfUploadsComplete(UploadService.java:685)
    at org.wordpress.android.ui.uploads.UploadService.stopServiceIfUploadsComplete(UploadService.java:670)
    at org.wordpress.android.ui.uploads.UploadService.onMediaUploaded(UploadService.java:966)
    at java.lang.reflect.Method.invoke(Method.java)
    at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:507)
    at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:501)
    at org.greenrobot.eventbus.HandlerPoster.handleMessage(HandlerPoster.java:67)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7660)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

When looking in the logs, I can see the user created a Story with 2 slides, but most of the time in the early stages when selecting the image to include as slides we've got other exceptions, in particular IllegalArgumentException: Volume storage not found. I wonder if that's related somehow (for example they've picked pictures from somewhere that is not really accessible for the optimizer to work with? But then FluxC was able to upload them apparently?).

These are the interesting bits from the logs (I cut most of it):


e/WordPress-UTILS: Error reading orientation of the file: /storage/emulated/0/DCIM/Camera/PXL_20201219_061706865.jpg - exception: Volume storage not found

generic
i/WordPress-STATS: šŸ”µ Tracked: story_text_changed, Properties: {"text_style":"unchanged"}
info
16:19:55
generic
i/WordPress-STATS: šŸ”µ Tracked: prepublishing_bottom_sheet_opened
info
16:20:08
generic
d/WordPress-API: Dispatching action: TaxonomyAction-FETCH_TAGS
info
16:20:08
generic
d/WordPress-API: TaxonomyStore onRegister
info
16:20:08
generic
i/WordPress-STATS: šŸ”µ Tracked: editor_post_publish_now_tapped, Properties: {"via":"prepublishing_nudges"}
info
16:20:12
generic
i/WordPress-STATS: šŸ”µ Tracked: prepublishing_bottom_sheet_dismissed
info
16:20:12
generic
i/WordPress-STATS: šŸ”µ Tracked: story_post_publish_tapped
info
16:20:12
generic
d/WordPress-API: Dispatching action: PostAction-UPDATE_POST
info
16:20:12
generic
d/WordPress-API: Dispatching action: ListAction-LIST_DATA_INVALIDATED

generic
e/WordPress-UTILS: Error reading orientation of the file: /storage/emulated/0/Pictures/WordPress/wp_story1608567613143_1.jpg - exception: Volume storage not found
info
16:20:13
generic
e/WordPress-UTILS: StackTrace: java.lang.IllegalArgumentException: Volume storage not found
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
    at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
    at android.content.ContentProviderProxy.query(ContentProviderNative.java:472)
    at android.content.ContentResolver.query(ContentResolver.java:1183)
    at android.content.ContentResolver.query(ContentResolver.java:1115)
    at android.content.ContentResolver.query(ContentResolver.java:1071)
    at org.wordpress.android.util.ImageUtils.getImageOrientation(ImageUtils.java:101)
    at org.wordpress.android.util.ImageUtils.optimizeImage(ImageUtils.java:548)
    at org.wordpress.android.util.WPMediaUtils.getOptimizedMedia(WPMediaUtils.java:72)
    at org.wordpress.android.util.MediaUtilsWrapper.getOptimizedMedia(MediaUtilsWrapper.kt:27)
    at org.wordpress.android.ui.posts.editor.media.OptimizeMediaUseCase.optimizeMedia(OptimizeMediaUseCase.kt:53)
    at org.wordpress.android.ui.posts.editor.media.OptimizeMediaUseCase.access$optimizeMedia(OptimizeMediaUseCase.kt:21)
    at org.wordpress.android.ui.posts.editor.media.OptimizeMediaUseCase$optimizeMediaIfSupportedAsync$2$invokeSuspend$$inlined$map$lambda$1.invokeSuspend(OptimizeMediaUseCase.kt:34)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:738)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
info
16:20:13
generic
i/WordPress-STATS: šŸ”µ Tracked: media_photo_optimized
info
16:20:13
generic
i/WordPress-STATS: šŸ”µ Tracked: media_photo_optimized

i/WordPress-STATS: šŸ”µ Tracked: story_post_save_remotely, Properties: {"blog_id":xxxxxx,"slide_qty":2,"site_type":"blog","is_jetpack":true}

i/WordPress-MEDIA: MediaUploadHandler > Dispatching upload action for media with local id: 72 and path: /data/user/0/org.wordpress.android/cache/wp_story1608567613122_08646609662768981357.jpg

state: stopped
screen: StoryComposerActivity
info
16:20:13
generic
i/WordPress-STATS: šŸ”µ Tracked: editor_session_end, Properties: {"has_unsupported_blocks":"0","editor":"wp_stories_creator","content_type":"new","session_id":"0c295b09-80c8-4083-be90-2648201666de","post_type":"post","blog_type":"jetpack","editor_has_hw_disabled":"0","outcome":"publish"}

generic
i/WordPress-MAIN: UploadService > Processing completed media with id 72 and local post id 43
info
16:20:25
exception
NullPointerException: mediaFile.mediaId must not be null
mzorz commented 3 years ago

Here's another case where the file seems to not exist when it's attempted to be uploaded, and then in the end the crash conditions are met when trying to process the Post for a media item that obviously can't have a remote mediaId (because it could not be uploaded in the first place):

generic
i/WordPress-STATS: šŸ”µ Tracked: media_service_upload_response_error, Properties: {"error_message":"local file path for media does not exist","error_status_code":0,"error_log":"Media doesn't have required data: local file path for media does not exist","error_type":"MALFORMED_MEDIA_ARG"}
info
11:07:37
generic
e/WordPress-MEDIA: Can't access the media file. It doesn't exists anymore!! Properties are not being tracked.
info
11:07:37
generic
i/WordPress-STATS: šŸ”µ Tracked: media_service_upload_started
info
11:07:37
generic
w/WordPress-MEDIA: MediaUploadHandler > No more media items to upload. Skipping this request.
info
11:07:37
generic
i/WordPress-MEDIA: MediaUploadHandler > Completed
info
11:07:37
generic
w/WordPress-MAIN: UploadService > Media upload failed for post 80 : MALFORMED_MEDIA_ARG: local file path for media does not exist
info
11:07:37
generic
d/WordPress-POSTS: updateNotificationErrorForPost: Es gab einen Fehler beim Hochladen der Medien in diesem Beitrag: Local file path for media does not exist.
info
11:07:37
generic
i/WordPress-STATS: šŸ”µ Tracked: my_site_icon_upload_unsuccessful
info
11:07:37
generic
i/WordPress-STATS: šŸ”µ Tracked: notification_shown, Properties: {"notification_type":"post_upload_error"}
info
11:07:37
exception
NullPointerException: mediaFile.mediaId must not be null
error
11:07:37
mzorz commented 3 years ago

Possible Sentry dupe here https://sentry.io/share/issue/55717409b678402d9825737efd7536d2/

mzorz commented 3 years ago

Closing via #13661

sentry-io[bot] commented 3 years ago

Sentry issue: WORDPRESS-ANDROID-122P