Upload of image attachment sometimes fails on mattermost for android

Summary
Issue in one concise sentence

In some time periods, when I click upload image, it fails with a image_picker_lib error.

Steps to reproduce
How can we reproduce the issue (what version are you using?)
Mattermost app version 2.3.0. Android v13, Samsung S21 Ultra, Mattermost server 7.7.1.

Expected behavior
When I upload an image, I expect the upload to be successful

Observed behavior

Usually the app works fine, but every few weeks, I experience this error. When I try to upload an image, it consistently fails with an image_picker_lib error. Sometimes after a while, it suddently works again. I can experience this issue for a duration of weeks, and then it’s gone again. It seems like the issue disappeared after I updated to 2.4.0, but this exact same issue has been going on and off the last year. Maybe it was the update to version 2.3 that broke the image picker, and that it was patched again in 2.4?

Below is a log capture from when the event happened:

2023-05-09 13:14:41.587 22976-22976 ViewRootIm...nActivity] com.mattermost.rn                    I  MSG_WINDOW_FOCUS_CHANGED 1 0
2023-05-09 13:14:41.587 22976-22976 ViewRootIm...nActivity] com.mattermost.rn                    I  mThreadedRenderer.initializeIfNeeded()#2 mSurface={isValid=true 0xb400007a4d7bb0f0}
2023-05-09 13:14:41.588 22976-22976 InputMethodManager      com.mattermost.rn                    D  startInputInner - Id : 0
2023-05-09 13:14:41.588 22976-22976 InputMethodManager      com.mattermost.rn                    I  startInputInner - mService.startInputOrWindowGainedFocus
2023-05-09 13:14:41.588  1546-6691  InputMetho...gerService system_server                        V  Unspecified window will hide input
2023-05-09 13:14:41.588  1546-6691  InputMetho...gerService system_server                        V  hideCurrentInputLocked : canceled, shouldHideSoftInput=false, mInputShown=false, mImeWindowVis=0
2023-05-09 13:14:41.588  1546-6691  InputMetho...Controller system_server                        I  setCurrentMethodNotVisible: mVisibleBound=false, mHasConnection=true, caller = com.android.server.inputmethod.InputMethodManagerService.hideCurrentInputLocked:4339 com.android.server.inputmethod.InputMethodManagerService.startInputOrWindowGainedFocusInternalLocked:4645 com.android.server.inputmethod.InputMethodManagerService.startInputOrWindowGainedFocusInternal:4423 com.android.server.inputmethod.InputMethodManagerService.startInputOrWindowGainedFocus:4362 com.android.internal.view.IInputMethodManager$Stub.onTransact:518 com.android.server.inputmethod.InputMethodManagerService.onTransact:2285 android.os.Binder.execTransactInternal:1321 android.os.Binder.execTransact:1280 <bottom of call stack> <bottom of call stack> 
2023-05-09 13:14:41.588  1546-6691  InputMetho...gerService system_server                        D  DESKTOP MODE! : 2
2023-05-09 13:14:41.588  1546-6691  InputMetho...gerService system_server                        D  NOT IN KNOX DESKTOP MODE!
2023-05-09 13:14:41.588  1546-6691  InputMetho...gerService system_server                        V  getDisplayIdOfInputMethodWindowToBeAdded: displayId=0
2023-05-09 13:14:41.589 11591-11591 InputTransport          com...ders.media.module:PhotoPicker  D  Input channel destroyed: 'ClientS', fd=114
2023-05-09 13:14:41.589  1546-6691  InputMetho...gerService system_server                        D  isImeSwitcherDisabledPackage : false
2023-05-09 13:14:41.589  1546-6691  InputMetho...gerService system_server                        D  shouldShowImeSwitcherLocked : checking vis : 3
2023-05-09 13:14:41.589  1546-6691  InputMetho...gerService system_server                        D  checkDisplayOfStartInputAndUpdateKeyboard: displayId=0, mFocusedDisplayId=0
2023-05-09 13:14:41.589  1546-6691  InputTransport          system_server                        D  Input channel constructed: 'ClientS', fd=370
2023-05-09 13:14:41.589  1546-6691  InputTransport          system_server                        D  Input channel destroyed: 'ClientS', fd=370
2023-05-09 13:14:41.590  1546-6691  RestrictionPolicy       system_server                        D  isScreenCaptureEnabled : ret=true userId=0
2023-05-09 13:14:41.590  1546-6691  WindowManager           system_server                        I  Cancelling animation restarting=true, leash=Surface(name=Surface(name=5ee6a81 InputMethod)/@0x6595f67 - animation-leash of insets_animation)/@0x7e26dbc
2023-05-09 13:14:41.590  1546-6691  WindowManager           system_server                        I  Reparenting to original parent: Surface(name=WindowToken{700a00f type=2011 android.os.Binder@f7b916e})/@0xff1c818, destroy=false, surface=Surface(name=5ee6a81 InputMethod)/@0x6595f67
2023-05-09 13:14:41.591  1546-6691  WindowManager           system_server                        I  Reparenting to leash, surface=Surface(name=5ee6a81 InputMethod)/@0x6595f67, leashParent=Surface(name=WindowToken{700a00f type=2011 android.os.Binder@f7b916e})/@0xff1c818
2023-05-09 13:14:41.591  1218-1278  SurfaceFlinger          surfaceflinger                       I  id=174654 createSurf flag=24004, Surface(name=5ee6a81 InputMethod)/@0x6595f67 - animation-leash of insets_animation#174654
2023-05-09 13:14:41.591 22976-22976 ViewRootIm...nActivity] com.mattermost.rn                    I  performTraversals params={(0,0)(fillxfill) sim={adjust=resize} ty=BASE_APPLICATION wanim=0x1030309
                                                                                                      fl=81810900
                                                                                                      pfl=16020040
                                                                                                      vsysui=510
                                                                                                      apr=LIGHT_NAVIGATION_BARS
                                                                                                      bhv=DEFAULT
                                                                                                      fitSides= naviIconColor=0
                                                                                                      sfl=100000}
2023-05-09 13:14:41.591 22976-22976 ViewRootIm...nActivity] com.mattermost.rn                    I  performTraversals mFirst=false windowShouldResize=false viewVisibilityChanged=false mForceNextWindowRelayout=false params={(0,0)(fillxfill) sim={adjust=resize} ty=BASE_APPLICATION wanim=0x1030309
                                                                                                      fl=81810900
                                                                                                      pfl=16020040
                                                                                                      vsysui=510
                                                                                                      apr=LIGHT_NAVIGATION_BARS
                                                                                                      bhv=DEFAULT
                                                                                                      fitSides= naviIconColor=0
                                                                                                      sfl=100000}
2023-05-09 13:14:41.591 20999-20999 GoogleInpu...hodService com...gle.android.inputmethod.latin  I  GoogleInputMethodService.onFinishInput():3261 
2023-05-09 13:14:41.593  1546-6691  WindowManager           system_server                        D  makeSurface duration=2 leash=Surface(name=Surface(name=5ee6a81 InputMethod)/@0x6595f67 - animation-leash of insets_animation)/@0x29e8fa1
2023-05-09 13:14:41.594 20999-20999 GoogleInpu...hodService com...gle.android.inputmethod.latin  I  GoogleInputMethodService.updateDeviceLockedStatus():2110 repeatCheckTimes = 0, locked = false
2023-05-09 13:14:41.594 20999-20999 InputMethodService      com...gle.android.inputmethod.latin  D  checkFocusedDisplay() display Id 0last 0
2023-05-09 13:14:41.594 20999-20999 GoogleInpu...hodService com...gle.android.inputmethod.latin  I  GoogleInputMethodService.onStartInput():1898 onStartInput(EditorInfo{inputType=0x0(NULL) imeOptions=0x0 privateImeOptions=null actionName=UNSPECIFIED actionLabel=null actionId=0 initialSelStart=-1 initialSelEnd=-1 initialCapsMode=0x0 hintText=null label=null packageName=com.mattermost.rn fieldId=-1 fieldName=null extras=Bundle[{displayId=0}] hintLocales=[]}, false)
2023-05-09 13:14:41.594 20999-20999 GoogleInpu...hodService com...gle.android.inputmethod.latin  I  GoogleInputMethodService.shouldHideHeaderOnInitialState():4088 ShouldHideHeaderOnInitialState = false
2023-05-09 13:14:41.595 20999-20999 GoogleInpu...hodService com...gle.android.inputmethod.latin  I  GoogleInputMethodService.updateDeviceLockedStatus():2110 repeatCheckTimes = 1, locked = false
2023-05-09 13:14:41.596  1546-7535  WindowManager           system_server                        V  Relayout Window{6bde08b u0 com.mattermost.rn/com.mattermost.rn.MainActivity}: viewVisibility=0 req=1080x2400 d0
2023-05-09 13:14:41.597  1546-7535  WindowManager           system_server                        V  Relayout hash=6bde08b, pid=22976, syncId=-1: mAttrs={(0,0)(fillxfill) sim={adjust=resize} ty=BASE_APPLICATION wanim=0x1030309
                                                                                                      fl=81810900
                                                                                                      pfl=16020040
                                                                                                      vsysui=510
                                                                                                      apr=LIGHT_NAVIGATION_BARS
                                                                                                      bhv=DEFAULT
                                                                                                      fitSides= naviIconColor=0
                                                                                                      sfl=100000}
2023-05-09 13:14:41.598 22976-22976 ViewRootIm...nActivity] com.mattermost.rn                    I  updateBlastSurfaceIfNeeded mBlastBufferQueue=0xb4000079bd879950 isSameSurfaceControl=true
2023-05-09 13:14:41.598 22976-22976 BLASTBufferQueue        com.mattermost.rn                    I  update, w= 1080 h= 2400 mName = ViewRootImpl@765faa6[MainActivity] mNativeObject= 0xb4000079bd879950 sc.mNativeObject= 0xb40000794d9bd190 format= -1 caller= android.view.ViewRootImpl.updateBlastSurfaceIfNeeded:2898 android.view.ViewRootImpl.relayoutWindow:9847 android.view.ViewRootImpl.performTraversals:3884 android.view.ViewRootImpl.doTraversal:3116 android.view.ViewRootImpl$TraversalRunnable.run:10885 android.view.Choreographer$CallbackRecord.run:1301 
2023-05-09 13:14:41.598 22976-22976 ViewRootIm...nActivity] com.mattermost.rn                    I  Relayout returned: old=(0,0,1080,2400) new=(0,0,1080,2400) req=(1080,2400)0 dur=7 res=0x0 s={true 0xb400007a4d7bb0f0} ch=false seqId=0
2023-05-09 13:14:41.599  1218-1218  Layer                   surfaceflinger                       I  id=174648 removeFromCurrentState Surface(name=5ee6a81 InputMethod)/@0x6595f67 - animation-leash of insets_animation#174648 (329)
2023-05-09 13:14:41.599  1218-1218  SurfaceFlinger          surfaceflinger                       I  id=174648 Removed Surface(name=5ee6a81 InputMethod)/@0x6595f67 - animation-leash of insets_animation#174648 (329)
2023-05-09 13:14:41.600  1218-1218  Layer                   surfaceflinger                       I  id=174648 Destroyed Surface(name=5ee6a81 InputMethod)/@0x6595f67 - animation-leash of insets_animation#174648
2023-05-09 13:14:41.603  1546-7535  InputMetho...gerService system_server                        D  isImeSwitcherDisabledPackage : false
2023-05-09 13:14:41.605 11591-11591 ViewRootIm...rActivity] com...ders.media.module:PhotoPicker  I  stopped(true) old = false
2023-05-09 13:14:41.605 11591-11591 ViewRootIm...rActivity] com...ders.media.module:PhotoPicker  I  WindowStopped on com.google.android.providers.media.module/com.android.providers.media.photopicker.PhotoPickerActivity set to true
2023-05-09 13:14:41.607  1546-1639  ActivityManager         system_server                        I  Killing 11690:com.google.android.apps.turbo/u0a245 (adj 999): empty #33
2023-05-09 13:14:41.608  7325-7343  SAMSUNGWALLET           com.samsung.android.spay             I  [Hint_ProcessStatusChange] fg Change, pid : 11591 , isNotify : true , isForeground : false , fg list : [22976]
2023-05-09 13:14:41.609  7325-8010  SAMSUNGWALLET           com.samsung.android.spay             I  [ResetData] getSAResetDialogFlag : false
2023-05-09 13:14:41.610  7325-7325  SAMSUNGWALLET           com.samsung.android.spay             I  [Hint_PayHintService] Hint Status - already invisible, skip hide : [4000000] - Disable on home
2023-05-09 13:14:41.613 20999-20999 InputMethodService      com...gle.android.inputmethod.latin  I  removeImeSurface
2023-05-09 13:14:41.613 20999-20999 MSHandlerLifeCycle      com...gle.android.inputmethod.latin  I  check: return. pkg=com.google.android.inputmethod.latin isActivity=false callers=com.android.internal.policy.DecorView.setVisibility:4416 android.app.Dialog.hide:767 android.inputmethodservice.InputMethodService.removeImeSurface:1290 android.inputmethodservice.InputMethodService.scheduleImeSurfaceRemoval:1279 android.inputmethodservice.InputMethodService.-$$Nest$mscheduleImeSurfaceRemoval:0 
2023-05-09 13:14:41.613 20999-20999 MSHandlerLifeCycle      com...gle.android.inputmethod.latin  I  removeMultiSplitHandler: no exist. decor=DecorView@767e9b2[InputMethod]
2023-05-09 13:14:41.614  1546-1649  libprocessgroup         system_server                        I  Successfully killed process cgroup uid 10245 pid 11690 in 6ms
2023-05-09 13:14:41.618 11591-11591 MSHandlerLifeCycle      com...ders.media.module:PhotoPicker  I  removeMultiSplitHandler: no exist. decor=DecorView@a3f968e[PhotoPickerActivity]
2023-05-09 13:14:41.622  1546-6691  CoreBackPreview         system_server                        D  Window{5046421 u0 com.google.android.providers.media.module/com.android.providers.media.photopicker.PhotoPickerActivity}: Setting back callback null
2023-05-09 13:14:41.622 11591-11591 MSHandlerLifeCycle      com...ders.media.module:PhotoPicker  I  removeMultiSplitHandler: no exist. decor=DecorView@a3f968e[PhotoPickerActivity]
2023-05-09 13:14:41.628 11591-11608 OpenGLRenderer          com...ders.media.module:PhotoPicker  D  setSurface called with nullptr
2023-05-09 13:14:41.628 11591-11608 OpenGLRenderer          com...ders.media.module:PhotoPicker  D  setSurface() destroyed EGLSurface
2023-05-09 13:14:41.628 11591-11608 OpenGLRenderer          com...ders.media.module:PhotoPicker  D  destroyEglSurface
2023-05-09 13:14:41.632 11591-11608 OpenGLRenderer          com...ders.media.module:PhotoPicker  D  endAllActiveAnimators on 0xb4000079dd7ef770 (RippleDrawable) with handle 0xb4000078ed785410
2023-05-09 13:14:41.633 11591-11591 ViewRootIm...rActivity] com...ders.media.module:PhotoPicker  I  dispatchDetachedFromWindow
2023-05-09 13:14:41.633  1546-6691  InputTransport          system_server                        D  Input channel destroyed: '5046421', fd=944
2023-05-09 13:14:41.633  1546-6691  InputManager-JNI        system_server                        W  Input channel object '5046421 com.google.android.providers.media.module/com.android.providers.media.photopicker.PhotoPickerActivity (client)' was disposed without first being removed with the input manager!
2023-05-09 13:14:41.633  1546-6691  InputTransport          system_server                        D  Input channel destroyed: '5046421', fd=996
2023-05-09 13:14:41.633  1546-6691  WindowManager           system_server                        V  Remove Window{5046421 u0 com.google.android.providers.media.module/com.android.providers.media.photopicker.PhotoPickerActivity}: mSurfaceController=Surface(name=com.google.android.providers.media.module/com.android.providers.media.photopicker.PhotoPickerActivity$_11591)/@0xf2dd987 mAnimatingExit=false mRemoveOnExit=false mHasSurface=true surfaceShowing=true animating=true app-animation=true mWillReplaceWindow=false mDisplayFrozen=false callers=com.android.server.wm.WindowState.removeIfPossible:3041 com.android.server.wm.WindowManagerService.removeWindow:2282 com.android.server.wm.Session.remove:236 android.view.IWindowSession$Stub.onTransact:743 com.android.server.wm.Session.onTransact:188 android.os.Binder.execTransactInternal:1316 
2023-05-09 13:14:41.635 11591-11591 InputTransport          com...ders.media.module:PhotoPicker  D  Input channel destroyed: '5046421', fd=84
2023-05-09 13:14:41.646  4873-1021  RecentModel             com.sec.android.app.launcher         I  onTaskStackChangedBackground
2023-05-09 13:14:41.651  1076-1076  Zygote                  zygote64                             I  Process 11690 exited due to signal 9 (Killed)
2023-05-09 13:14:41.656  1546-1640  WindowManager           system_server                        I  Reparenting to original parent: Surface(name=Task=28313)/@0xe726dde, destroy=true, surface=Surface(name=ActivityRecord{9dcb6d4 u0 com.google.android.providers.media.module/com.android.providers.media.photopicker.PhotoPickerActivity} t28313})/@0x8fe977e
2023-05-09 13:14:41.656  1546-1640  WindowManager           system_server                        V  Setting visibility of Window{5046421 u0 com.google.android.providers.media.module/com.android.providers.media.photopicker.PhotoPickerActivity EXITING}: false, caller=com.android.server.wm.WindowContainer.sendAppVisibilityToClients:1246 com.android.server.wm.WindowToken.setClientVisible:431 com.android.server.wm.ActivityRecord.setClientVisible:7685 com.android.server.wm.ActivityRecord.onAnimationFinished:8584 com.android.server.wm.WindowContainer$$ExternalSyntheticLambda4.onAnimationFinished:2 
2023-05-09 13:14:41.656  1546-1640  WindowManager           system_server                        E  win=Window{5046421 u0 com.google.android.providers.media.module/com.android.providers.media.photopicker.PhotoPickerActivity EXITING} destroySurfaces: appStopped=false cleanupOnResume=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true win.mViewVisibility=0 caller=com.android.server.wm.ActivityRecord.destroySurfaces:6533 com.android.server.wm.ActivityRecord.destroySurfaces:6514 com.android.server.wm.WindowState.onExitAnimationDone:5981 com.android.server.wm.ActivityRecord$$ExternalSyntheticLambda10.accept:2 java.util.ArrayList.forEach:1262 com.android.server.wm.ActivityRecord.onAnimationFinished:8601 com.android.server.wm.WindowContainer$$ExternalSyntheticLambda4.onAnimationFinished:2 
2023-05-09 13:14:41.656  1546-1640  WindowManager           system_server                        I  Destroying surface Surface(name=com.google.android.providers.media.module/com.android.providers.media.photopicker.PhotoPickerActivity$_11591)/@0xf2dd987 called by com.android.server.wm.WindowStateAnimator.destroySurface:942 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:536 com.android.server.wm.WindowState.destroySurfaceUnchecked:4306 com.android.server.wm.WindowState.destroySurface:4280 com.android.server.wm.ActivityRecord.destroySurfaces:6533 com.android.server.wm.ActivityRecord.destroySurfaces:6514 com.android.server.wm.WindowState.onExitAnimationDone:5981 com.android.server.wm.ActivityRecord$$ExternalSyntheticLambda10.accept:2 
2023-05-09 13:14:41.657  1546-1640  RestrictionPolicy       system_server                        D  isScreenCaptureEnabled : ret=true userId=0

Hi @elias.sorensen , thanks for the detailed report and welcome to the Mattermost forums!

I’ve alerted the mobile developers about this topic and hope someone will share insights ASAP.

Alright, just got a quick update - without being able to reproduce the issue or without seeing logs it’s hard to diagnose the issue. It’s at least not a known issue for the developers, so if this ever happens again to you, please let us know here and we’ll tackle it from there.