Essentials
Essentials copied to clipboard
[Bug] Calling an async method after PickPhotoAsync or CapturePhotoAsync crashes the method
Description
Calling an async method after PickPhotoAsync
or CapturePhotoAsync
sort of crashes the method. No exception is thrown, but the method just ends when it reaches the awaiting method after calling either of the above methods.
Did some looking around and found this on StackOverflow, seams like the same issue - https://stackoverflow.com/questions/65586253/xamarin-essentials-media-picker-keeps-crashing-my-app-no-exception-or-erros
Here is my current code, after calling PickPhotoAsync
code continue, but when it goes to open the alert the method just stops and no alert appears -
FileResult photo = await MediaPicker.PickPhotoAsync();
// Check for null (not selected)
if (photo == null) return null;
// Check for duplicated selected photo
if (fileNames?.Any(x => x.Equals(photo.FileName)) ?? false)
{
await UserDialogs.Instance.AlertAsync(
AppResources.DisplayMessageImageAlreadyAddedBody,
AppResources.DisplayMessageImageAlreadyAdded,
AppResources.BtnOk);
return null;
}
Here is the debug logs (before and after it failed)
[AppCenterCrashes] The memory running level (20) was saved.
[EGL_emulation] eglMakeCurrent: 0x70b1b4e1f7a0: ver 2 0 (tinfo 0x70b1b47d6000)
[EGL_emulation] eglMakeCurrent: 0x70b1b4e1f7a0: ver 2 0 (tinfo 0x70b1b47d6000)
[EGL_emulation] eglMakeCurrent: 0x70b1b4e1f7a0: ver 2 0 (tinfo 0x70b1b47d6000)
[WindowManager]
[WindowManager] android.view.WindowLeaked: Activity crc64a0e0a82d0db9a07d.IntermediateActivity has leaked window DecorView@6f9a795[IntermediateActivity] that was originally added here
[WindowManager] at android.view.ViewRootImpl.<init>(ViewRootImpl.java:597)
[WindowManager] at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:377)
[WindowManager] at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:95)
[WindowManager] at android.app.Dialog.show(Dialog.java:342)
[WindowManager] at mono.java.lang.RunnableImplementor.n_run(Native Method)
[WindowManager] at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
[WindowManager] at android.app.Activity.runOnUiThread(Activity.java:6904)
[WindowManager] at mono.java.lang.RunnableImplementor.n_run(Native Method)
[WindowManager] at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
[WindowManager] at android.os.Handler.handleCallback(Handler.java:883)
[WindowManager] at android.os.Handler.dispatchMessage(Handler.java:100)
[WindowManager] at android.os.Looper.loop(Looper.java:214)
[Window03-04 16:40:53.602 E] at android.app.ActivityThread.main(ActivityThread.java:7356)
[WindowManager] at java.lang.reflect.Method.invoke(Native Method)
[WindowManager] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
[WindowManager] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
[EGL_emulation] eglMakeCurrent: 0x70b1b4e1f7a0: ver 2 0 (tinfo 0x70b1b47d6000)
[chatty] uid=10151(uk.gov.cardiff.CardiffGov.Android) RenderThread identical 6 lines
[EGL_emulation] eglMakeCurrent: 0x70b1b4e1f7a0: ver 2 0 (tinfo 0x70b1b47d6000)
[EGL_emulation] eglMakeCurrent: 0x70b1b4e1f7a0: ver 2 0 (tinfo 0x70b1b47d6000)
[chatty] uid=10151(uk.gov.cardiff.CardiffGov.Android) RenderThread identical 4 lines
[EGL_emulation] eglMakeCurrent: 0x70b1b4e1f7a0: ver 2 0 (tinfo 0x70b1b47d6000)
[OpenGLRenderer] endAllActiveAnimators on 0x70b1acc04400 (AlertController$RecycleListView) with handle 0x70b1a50cac00
[EGL_emulation] eglMakeCurrent: 0x70b1b4e1f7a0: ver 2 0 (tinfo 0x70b1b47d6000)
[chatty] uid=10151(uk.gov.cardiff.CardiffGov.Android) RenderThread identical 2 lines
[EGL_emulation] eglMakeCurrent: 0x70b1b4e1f7a0: ver 2 0 (tinfo 0x70b1b47d6000)
[diffGov.Androi] Explicit concurrent copying GC freed 61773(1904KB) AllocSpace objects, 3(396KB) LOS objects, 47% free, 6737KB/12MB, paused 503us total 19.409ms
[System] A resource failed to call close.
[System] A resource failed to call close.
And here is the device logs -
Time Device Name Type PID Tag Message
03-04 16:47:52.685 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: a: input svInfo.flags is 8
03-04 16:47:54.992 pixel_3a_q_10_0_-_api_29 Info 24244 BgTaskExecutorImpl Starting PERIODIC background task RESTORE_SPEAKER_MODEL.
03-04 16:47:54.992 pixel_3a_q_10_0_-_api_29 Info 24244 BgTaskExecutorImpl Starting PERIODIC background task REFRESH_SEARCH_HISTORY.
03-04 16:47:54.685 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: b: input svInfo.flags is 8
03-04 16:47:54.685 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: a: input svInfo.flags is 8
03-04 16:47:53.685 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: b: input svInfo.flags is 8
03-04 16:47:53.685 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: a: input svInfo.flags is 8
03-04 16:47:52.685 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: b: input svInfo.flags is 8
03-04 16:47:51.685 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: b: input svInfo.flags is 8
03-04 16:47:51.685 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: a: input svInfo.flags is 8
03-04 16:47:51.308 pixel_3a_q_10_0_-_api_29 Warning 1780 audio_hw_generic Not supplying enough data to HAL, expected position 30784384 , only wrote 30588436
03-04 16:47:51.030 pixel_3a_q_10_0_-_api_29 Debug 3338 EGL_emulation eglMakeCurrent: 0x70b20805ce60: ver 2 0 (tinfo 0x70b208018800)
03-04 16:47:50.801 pixel_3a_q_10_0_-_api_29 Warning 2039 WindowManager Failed looking up window callers=com.android.server.wm.WindowManagerService.windowForClientLocked:5281 com.android.server.wm.WindowManagerService.removeWindow:1753 com.android.server.wm.Session.remove:176
03-04 16:47:50.792 pixel_3a_q_10_0_-_api_29 Error 22924 WindowManager android.view.WindowLeaked: Activity crc64a0e0a82d0db9a07d.IntermediateActivity has leaked window DecorView@d247622[IntermediateActivity] that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:597)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:377)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:95)
at android.app.Dialog.show(Dialog.java:342)
at mono.java.lang.RunnableImplementor.n_run(Native Method)
at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
at android.app.Activity.runOnUiThread(Activity.java:6904)
at crc64a0e0a82d0db9a07d.IntermediateActivity.n_onActivityResult(Native Method)
at crc64a0e0a82d0db9a07d.IntermediateActivity.onActivityResult(IntermediateActivity.java:47)
at android.app.Activity.dispatchActivityResult(Activity.java:8110)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4838)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4886)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
03-04 16:47:50.792 pixel_3a_q_10_0_-_api_29 Error 22924 WindowManager
03-04 16:47:50.773 pixel_3a_q_10_0_-_api_29 Debug 2209 EGL_emulation eglMakeCurrent: 0x70b1bc066e20: ver 2 0 (tinfo 0x70b1bc1fe040)
03-04 16:47:50.761 pixel_3a_q_10_0_-_api_29 Info 2209 chatty uid=10103(com.android.systemui) RenderThread identical 7 lines
03-04 16:47:50.690 pixel_3a_q_10_0_-_api_29 Debug 2209 EGL_emulation eglMakeCurrent: 0x70b1bc066e20: ver 2 0 (tinfo 0x70b1bc1fe040)
03-04 16:47:50.685 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: b: input svInfo.flags is 8
03-04 16:47:50.685 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: a: input svInfo.flags is 8
03-04 16:47:50.685 pixel_3a_q_10_0_-_api_29 Debug 2209 EGL_emulation eglMakeCurrent: 0x70b1bc066e20: ver 2 0 (tinfo 0x70b1bc1fe040)
03-04 16:47:50.672 pixel_3a_q_10_0_-_api_29 Info 2209 chatty uid=10103(com.android.systemui) RenderThread identical 4 lines
03-04 16:47:50.633 pixel_3a_q_10_0_-_api_29 Debug 2209 EGL_emulation eglMakeCurrent: 0x70b1bc066e20: ver 2 0 (tinfo 0x70b1bc1fe040)
03-04 16:47:50.630 pixel_3a_q_10_0_-_api_29 Info 2523 GoogleInputMethodService GoogleInputMethodService.onStartInput():1914
03-04 16:47:50.630 pixel_3a_q_10_0_-_api_29 Info 2523 GoogleInputMethodService GoogleInputMethodService.onFinishInput():3311
03-04 16:47:50.628 pixel_3a_q_10_0_-_api_29 Debug 2209 EGL_emulation eglMakeCurrent: 0x70b1bc066e20: ver 2 0 (tinfo 0x70b1bc1fe040)
03-04 16:47:50.623 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:50.623 pixel_3a_q_10_0_-_api_29 Info 2039 chatty uid=1000(system) android.anim identical 8 lines
03-04 16:47:50.623 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:50.613 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:50.603 pixel_3a_q_10_0_-_api_29 Debug 1790 gralloc_ranchu gralloc_alloc: Creating ashmem region of size 9592832
03-04 16:47:50.598 pixel_3a_q_10_0_-_api_29 Info 1790 chatty uid=1000(system) HwBinder:1790_2 identical 1 line
03-04 16:47:50.592 pixel_3a_q_10_0_-_api_29 Debug 1790 gralloc_ranchu gralloc_alloc: Creating ashmem region of size 9592832
03-04 16:47:50.567 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:50.567 pixel_3a_q_10_0_-_api_29 Info 2039 chatty uid=1000(system) Binder:2039_9 identical 8 lines
03-04 16:47:50.567 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:50.556 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:50.552 pixel_3a_q_10_0_-_api_29 Debug 1790 gralloc_ranchu gralloc_alloc: Creating ashmem region of size 3014656
03-04 16:47:50.550 pixel_3a_q_10_0_-_api_29 Info 1790 chatty uid=1000(system) HwBinder:1790_2 identical 1 line
03-04 16:47:50.545 pixel_3a_q_10_0_-_api_29 Debug 1790 gralloc_ranchu gralloc_alloc: Creating ashmem region of size 3014656
03-04 16:47:50.533 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:50.533 pixel_3a_q_10_0_-_api_29 Info 2039 chatty uid=1000(system) Binder:2039_9 identical 8 lines
03-04 16:47:50.533 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:50.445 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:50.445 pixel_3a_q_10_0_-_api_29 Info 2039 chatty uid=1000(system) Binder:2039_1B identical 38 lines
03-04 16:47:50.441 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:49.685 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: b: input svInfo.flags is 8
03-04 16:47:49.685 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: a: input svInfo.flags is 8
03-04 16:47:48.866 pixel_3a_q_10_0_-_api_29 Debug 22924 AppCenterCrashes The memory running level (20) was saved.
03-04 16:47:48.853 pixel_3a_q_10_0_-_api_29 Debug 22924 Mono Assembly Ref addref Xamarin.Forms.Platform.Android[0x70b1bcc34380] -> System.Xml[0x70b2080fdf00]: 8
03-04 16:47:48.853 pixel_3a_q_10_0_-_api_29 Debug 22924 Mono Loading reference 21 of /data/data/uk.gov.cardiff.CardiffGov.Android/files/.__override__/Xamarin.Forms.Platform.Android.dll asmctx DEFAULT, looking for System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
03-04 16:47:48.853 pixel_3a_q_10_0_-_api_29 Debug 22924 Mono Requesting loading reference 21 (of 22) of /data/data/uk.gov.cardiff.CardiffGov.Android/files/.__override__/Xamarin.Forms.Platform.Android.dll
03-04 16:47:48.841 pixel_3a_q_10_0_-_api_29 Debug 22924 Mono Assembly Ref addref Xamarin.Forms.Platform.Android[0x70b1bcc34380] -> System.Runtime.Serialization[0x70b1b28efd00]: 3
03-04 16:47:48.841 pixel_3a_q_10_0_-_api_29 Debug 22924 Mono Loading reference 12 of /data/data/uk.gov.cardiff.CardiffGov.Android/files/.__override__/Xamarin.Forms.Platform.Android.dll asmctx DEFAULT, looking for System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
03-04 16:47:48.841 pixel_3a_q_10_0_-_api_29 Debug 22924 Mono Requesting loading reference 12 (of 22) of /data/data/uk.gov.cardiff.CardiffGov.Android/files/.__override__/Xamarin.Forms.Platform.Android.dll
03-04 16:47:48.829 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:48.684 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: b: input svInfo.flags is 8
03-04 16:47:48.684 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: a: input svInfo.flags is 8
03-04 16:47:48.550 pixel_3a_q_10_0_-_api_29 Debug 2209 EGL_emulation eglMakeCurrent: 0x70b1bc066e20: ver 2 0 (tinfo 0x70b1bc1fe040)
03-04 16:47:48.546 pixel_3a_q_10_0_-_api_29 Info 2209 chatty uid=10103(com.android.systemui) RenderThread identical 11 lines
03-04 16:47:48.484 pixel_3a_q_10_0_-_api_29 Warning 2039 RemoteAppPredictionService could not bind to Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } using flags 67108865
03-04 16:47:48.484 pixel_3a_q_10_0_-_api_29 Warning 2039 ActivityManager Unable to start service Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } U=0: not found
03-04 16:47:48.484 pixel_3a_q_10_0_-_api_29 Warning 2039 RemoteAppPredictionService could not bind to Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } using flags 67108865
03-04 16:47:48.484 pixel_3a_q_10_0_-_api_29 Warning 2039 ActivityManager Unable to start service Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } U=0: not found
03-04 16:47:48.452 pixel_3a_q_10_0_-_api_29 Debug 2209 EGL_emulation eglMakeCurrent: 0x70b1bc066e20: ver 2 0 (tinfo 0x70b1bc1fe040)
03-04 16:47:48.442 pixel_3a_q_10_0_-_api_29 Info 2523 GoogleInputMethodService GoogleInputMethodService.onStartInput():1914
03-04 16:47:48.442 pixel_3a_q_10_0_-_api_29 Debug 2209 EGL_emulation eglMakeCurrent: 0x70b1bc066e20: ver 2 0 (tinfo 0x70b1bc1fe040)
03-04 16:47:48.441 pixel_3a_q_10_0_-_api_29 Info 2523 GoogleInputMethodService GoogleInputMethodService.onFinishInput():3311
03-04 16:47:48.434 pixel_3a_q_10_0_-_api_29 Debug 2209 EGL_emulation eglMakeCurrent: 0x70b1bc066e20: ver 2 0 (tinfo 0x70b1bc1fe040)
03-04 16:47:48.432 pixel_3a_q_10_0_-_api_29 Info 2039 ActivityTaskManager Displayed com.android.documentsui/.picker.PickActivity: +48ms
03-04 16:47:48.418 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.418 pixel_3a_q_10_0_-_api_29 Info 2039 chatty uid=1000(system) android.anim identical 8 lines
03-04 16:47:48.418 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.405 pixel_3a_q_10_0_-_api_29 Debug 3338 EGL_emulation eglMakeCurrent: 0x70b20805ce60: ver 2 0 (tinfo 0x70b208018800)
03-04 16:47:48.401 pixel_3a_q_10_0_-_api_29 Debug 1790 gralloc_ranchu gralloc_alloc: Creating ashmem region of size 9592832
03-04 16:47:48.397 pixel_3a_q_10_0_-_api_29 Debug 1790 gralloc_ranchu gralloc_alloc: Creating ashmem region of size 9592832
03-04 16:47:48.391 pixel_3a_q_10_0_-_api_29 Debug 1790 gralloc_ranchu gralloc_alloc: Creating ashmem region of size 9592832
03-04 16:47:48.366 pixel_3a_q_10_0_-_api_29 Warning 3338 LastAccessedStorage Caused by: java.lang.NullPointerException: name
at com.android.internal.util.Preconditions.checkNotNull(Preconditions.java:133)
at android.content.ContentResolver.acquireUnstableContentProviderClient(ContentResolver.java:2220)
at com.android.documentsui.DocumentsApplication.acquireUnstableProviderOrThrow(DocumentsApplication.java:64)
at com.android.documentsui.base.DocumentInfo.updateFromUri(DocumentInfo.java:195)
... 13 more
03-04 16:47:48.366 pixel_3a_q_10_0_-_api_29 Warning 3338 LastAccessedStorage java.io.FileNotFoundException: name
at com.android.documentsui.base.DocumentInfo.asFileNotFoundException(DocumentInfo.java:374)
at com.android.documentsui.base.DocumentInfo.updateFromUri(DocumentInfo.java:203)
at com.android.documentsui.base.DocumentInfo.updateSelf(DocumentInfo.java:188)
at com.android.documentsui.base.DocumentStack.updateDocuments(DocumentStack.java:239)
at com.android.documentsui.base.DocumentStack.fromLastAccessedCursor(DocumentStack.java:254)
at com.android.documentsui.picker.LastAccessedStorage$RuntimeLastAccessedStorage.getLastAccessed(LastAccessedStorage.java:67)
at com.android.documentsui.picker.LoadLastAccessedStackTask.run(LoadLastAccessedStackTask.java:60)
at com.android.documentsui.picker.LoadLastAccessedStackTask.run(LoadLastAccessedStackTask.java:37)
at com.android.documentsui.base.CheckedTask.doInBackground(CheckedTask.java:65)
at android.os.AsyncTask$3.call(AsyncTask.java:378)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
03-04 16:47:48.366 pixel_3a_q_10_0_-_api_29 Warning 3338 LastAccessedStorage Failed to resume:
03-04 16:47:48.344 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.344 pixel_3a_q_10_0_-_api_29 Info 2039 chatty uid=1000(system) Binder:2039_B identical 8 lines
03-04 16:47:48.344 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.343 pixel_3a_q_10_0_-_api_29 Warning 3338 ActivityThread handleWindowVisibility: no activity for token android.os.BinderProxy@178352c
03-04 16:47:48.343 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.343 pixel_3a_q_10_0_-_api_29 Info 2039 chatty uid=1000(system) Binder:2039_B identical 48 lines
03-04 16:47:48.341 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.335 pixel_3a_q_10_0_-_api_29 Info 2039 ActivityTaskManager START u0 {act=android.intent.action.GET_CONTENT typ=image/* flg=0x3000000 cmp=com.android.documentsui/.picker.PickActivity} from uid 10151
03-04 16:47:48.329 pixel_3a_q_10_0_-_api_29 Warning 3314 ActivityThread handleWindowVisibility: no activity for token android.os.BinderProxy@c71c349
03-04 16:47:48.329 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.328 pixel_3a_q_10_0_-_api_29 Info 2039 chatty uid=1000(system) Binder:2039_9 identical 48 lines
03-04 16:47:48.326 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.324 pixel_3a_q_10_0_-_api_29 Warning 3285 APSResolverComparator Score requested for unknown component.
03-04 16:47:48.324 pixel_3a_q_10_0_-_api_29 Warning 2039 RemoteAppPredictionService could not bind to Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } using flags 67108865
03-04 16:47:48.324 pixel_3a_q_10_0_-_api_29 Warning 2039 ActivityManager Unable to start service Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } U=0: not found
03-04 16:47:48.317 pixel_3a_q_10_0_-_api_29 Warning 2039 RemoteAppPredictionService could not bind to Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } using flags 67108865
03-04 16:47:48.317 pixel_3a_q_10_0_-_api_29 Warning 2039 ActivityManager Unable to start service Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } U=0: not found
03-04 16:47:48.312 pixel_3a_q_10_0_-_api_29 Info 2039 ActivityTaskManager START u0 {flg=0x3000000 cmp=com.android.systemui/.chooser.ChooserActivity (has extras)} from uid 1000
03-04 16:47:48.307 pixel_3a_q_10_0_-_api_29 Warning 2039 RemoteAppPredictionService could not bind to Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } using flags 67108865
03-04 16:47:48.307 pixel_3a_q_10_0_-_api_29 Warning 2039 ActivityManager Unable to start service Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } U=0: not found
03-04 16:47:48.306 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:48.300 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.300 pixel_3a_q_10_0_-_api_29 Info 2039 chatty uid=1000(system) Binder:2039_1B identical 14 lines
03-04 16:47:48.297 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.297 pixel_3a_q_10_0_-_api_29 Warning 3285 ActivityThread handleWindowVisibility: no activity for token android.os.BinderProxy@9231247
03-04 16:47:48.296 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.296 pixel_3a_q_10_0_-_api_29 Info 2039 chatty uid=1000(system) Binder:2039_1B identical 22 lines
03-04 16:47:48.296 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.282 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:48.282 pixel_3a_q_10_0_-_api_29 Debug 1790 gralloc_ranchu gralloc_alloc: Creating ashmem region of size 9592832
03-04 16:47:48.278 pixel_3a_q_10_0_-_api_29 Info 1790 chatty uid=1000(system) [email protected] identical 1 line
03-04 16:47:48.273 pixel_3a_q_10_0_-_api_29 Debug 1790 gralloc_ranchu gralloc_alloc: Creating ashmem region of size 9592832
03-04 16:47:48.246 pixel_3a_q_10_0_-_api_29 Info 2039 ActivityTaskManager START u0 {act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity (has extras)} from uid 10151
03-04 16:47:48.236 pixel_3a_q_10_0_-_api_29 Warning 22924 ActivityThread handleWindowVisibility: no activity for token android.os.BinderProxy@52d7fbb
03-04 16:47:48.225 pixel_3a_q_10_0_-_api_29 Warning 2039 android.os.Debug failed to get memory consumption info: -1
03-04 16:47:48.225 pixel_3a_q_10_0_-_api_29 Error 2039 memtrack Couldn't load memtrack module
03-04 16:47:48.223 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.223 pixel_3a_q_10_0_-_api_29 Info 2039 chatty uid=1000(system) Binder:2039_1B identical 38 lines
03-04 16:47:48.221 pixel_3a_q_10_0_-_api_29 Warning 2039 InputReader Device has associated, but no associated display id.
03-04 16:47:48.212 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:48.209 pixel_3a_q_10_0_-_api_29 Error 2039 InputDispatcher Window handle Window{d32e68 u0 uk.gov.cardiff.CardiffGov.Android/crc64f1e19bb4ee2769d2.MainActivity} has no registered input channel
03-04 16:47:48.202 pixel_3a_q_10_0_-_api_29 Debug 22924 OpenGLRenderer endAllActiveAnimators on 0x70b19c991c00 (RippleDrawable) with handle 0x70b1a43066c0
03-04 16:47:48.201 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:48.197 pixel_3a_q_10_0_-_api_29 Info 22924 chatty uid=10151(uk.gov.cardiff.CardiffGov.Android) RenderThread identical 2 lines
03-04 16:47:48.193 pixel_3a_q_10_0_-_api_29 Info 2039 ActivityTaskManager START u0 {cmp=uk.gov.cardiff.CardiffGov.Android/crc64a0e0a82d0db9a07d.IntermediateActivity (has extras)} from uid 10151
03-04 16:47:48.162 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:47.684 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: b: input svInfo.flags is 8
03-04 16:47:47.684 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: a: input svInfo.flags is 8
03-04 16:47:47.028 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:47.019 pixel_3a_q_10_0_-_api_29 Info 22924 chatty uid=10151(uk.gov.cardiff.CardiffGov.Android) RenderThread identical 2 lines
03-04 16:47:46.987 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:46.987 pixel_3a_q_10_0_-_api_29 Debug 1790 gralloc_ranchu gralloc_alloc: Creating ashmem region of size 3424256
03-04 16:47:46.985 pixel_3a_q_10_0_-_api_29 Info 1790 chatty uid=1000(system) [email protected] identical 1 line
03-04 16:47:46.982 pixel_3a_q_10_0_-_api_29 Debug 1790 gralloc_ranchu gralloc_alloc: Creating ashmem region of size 3424256
03-04 16:47:46.954 pixel_3a_q_10_0_-_api_29 Error 2039 InputDispatcher Window handle Window{dd5dee4 u0 uk.gov.cardiff.CardiffGov.Android/crc64f1e19bb4ee2769d2.MainActivity} has no registered input channel
03-04 16:47:46.944 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:46.936 pixel_3a_q_10_0_-_api_29 Error 2039 InputDispatcher Window handle Window{dd5dee4 u0 uk.gov.cardiff.CardiffGov.Android/crc64f1e19bb4ee2769d2.MainActivity} has no registered input channel
03-04 16:47:46.934 pixel_3a_q_10_0_-_api_29 Debug 22924 OpenGLRenderer endAllActiveAnimators on 0x70b1a4836f00 (AlertController$RecycleListView) with handle 0x70b1a44b88e0
03-04 16:47:46.933 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:46.891 pixel_3a_q_10_0_-_api_29 Debug 22924 Mono GC_MINOR: (Nursery full) time 12.51ms, stw 14.08ms promoted 832K major size: 13856K in use: 12334K los size: 5120K in use: 4174K
03-04 16:47:46.891 pixel_3a_q_10_0_-_api_29 Debug 22924 Mono GC_BRIDGE: Complete, was running for 17.73ms
03-04 16:47:46.891 pixel_3a_q_10_0_-_api_29 Debug 22924 Mono GC_TAR_BRIDGE bridges 2174 objects 74758 opaque 26619 colors 2174 colors-bridged 2174 colors-visible 2174 xref 3 cache-hit 0 cache-semihit 0 cache-miss 0 setup 0.06ms tarjan 8.28ms scc-setup 0.15ms gather-xref 0.02ms xref-setup 0.01ms cleanup 0.96ms
03-04 16:47:46.887 pixel_3a_q_10_0_-_api_29 Info 22924 diffGov.Androi Explicit concurrent copying GC freed 25163(1248KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 5442KB/10MB, paused 196us total 12.531ms
03-04 16:47:46.835 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:46.825 pixel_3a_q_10_0_-_api_29 Warning 1780 audio_hw_generic Not supplying enough data to HAL, expected position 30390810 , only wrote 30390797
03-04 16:47:46.821 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:46.819 pixel_3a_q_10_0_-_api_29 Info 22924 chatty uid=10151(uk.gov.cardiff.CardiffGov.Android) RenderThread identical 4 lines
03-04 16:47:46.769 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:46.684 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: b: input svInfo.flags is 8
03-04 16:47:46.684 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: a: input svInfo.flags is 8
03-04 16:47:45.684 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: b: input svInfo.flags is 8
03-04 16:47:45.684 pixel_3a_q_10_0_-_api_29 Error 1789 GnssHAL_GnssInterface gnssSvStatusCb: a: input svInfo.flags is 8
03-04 16:47:45.494 pixel_3a_q_10_0_-_api_29 Debug 22924 EGL_emulation eglMakeCurrent: 0x70b1b4dbb340: ver 2 0 (tinfo 0x70b1b4620cc0)
03-04 16:47:45.482 pixel_3a_q_10_0_-_api_29 Info 22924 chatty uid=10151(uk.gov.cardiff.CardiffGov.Android) RenderThread identical 36 lines
Expected Behavior
Show alert
Actual Behavior
No alert and method ends
Basic Information
- Version with issue: 1.6.1
- Last known good version: Attempting to migrate from Plugin.Media to essentials
- IDE: VS2019
- Platform Target Frameworks:
- iOS:
- Android: 11.0
- UWP:
- Android Support Library Version:
- Nuget Packages:
- Affected Devices:
I'm seeing this crash without a call after.
private static async Task<FileResult> _takePhotoGetFile()
{
FileResult file = null;
await MainThread.InvokeOnMainThreadAsync(async () =>
{
try
{
if (!MediaPicker.IsCaptureSupported)
{
Debug.WriteLine("Camera capture not supported");
throw new Exception("No camera available");
}
file = await MediaPicker.CapturePhotoAsync();
}
catch(Exception ex)
{
Logger.TrackException(ex, Tag);
}
});
return file;
}
This crashes at the file = await MediaPicker.CapturePhotoAsync() line without any exception being caught
Hmmm I tested this in our sample app in the repo and couldnt' reproduce. I did
try
{
var photo = await MediaPicker.PickPhotoAsync();
await LoadPhotoAsync(photo);
await DisplayAlertAsync("test");
Console.WriteLine($"PickPhotoAsync COMPLETED: {PhotoPath}");
}
All seemed to work. Do you have a different launch mode for your app or are you testing it with keep activities alive off?
Hi James
I take advantage of the thread to plan the error I am having for using Visual Studio Mac and testing on a simulate.
I have been using your plugins, but well you recommend I have migrated both to the use of Xamarin.Essential the part of permissions and media.
Testing in Xamarin.iOS I have the following error: First the value of the property MediaPicher.IsCaptureSupprted is always false then when executing the method MediaPicker.CapturePhotoAsync() this error is generated:
FrameworkTest.Xamarin.Essentials.MediaManageException: Specified method is not supported. at FrameworkTest.Xamarin.Essentials.MediaManage.TakePhotoAsync () [0x001c0] in /Users/user192607/Projects/Projects Framework/Framework.Test/Framework.Test.Mobile/Framework.Test.Mobile/Framework/Media/MediaManage.cs:48 at Framework.Test.Mobile.ViewModels.HomeViewModel.OnTakePhotoAsync () [0x0001a] in /Users/user192607/Projects/Projects Framework/Framework.Test/Framework.Test.Mobile/Framework.Test.Mobile/ViewModels/Home/HomeViewModel.cs:102 at Framework.Test.Mobile.ViewModels.HomeViewModel.OnStart () [0x00020] in /Users/user192607/Projects/Projects Framework/Framework.Test/Framework.Test.Mobile/Framework.Test.Mobile/ViewModels/Home/HomeViewModel.cs:123 at Framework.Test.Mobile.ViewModels.HomeViewModel.<Initialize>b__11_0 () [0x0001f] in /Users/user192607/Projects/Projects Framework/Framework.Test/Framework.Test.Mobile/Framework.Test.Mobile/ViewModels/Home/HomeViewModel.cs:57 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:178 at at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65 at Framework.Test.Mobile.iOS.Application.Main (System.String[] args) [0x00001] in /Users/user192607/Projects/Projects Framework/Framework.Test/Framework.Test.Mobile/Framework.Test.Mobile.iOS/Main.cs:17
May you help to fix this error.
Regards
Capturing a photos is not supported on iOS simulators only devices.
James, Thanks you
I apologize but I would like to ask you how do I know if my app run over a simulator.
Regards
See https://docs.microsoft.com/en-us/xamarin/essentials/device-information?context=xamarin%2Fxamarin-forms&tabs=ios#device-type
We are getting the same error in Essentials 1.7:
[WindowManager] android.view.WindowLeaked: Activity crc64a0e0a82d0db9a07d.IntermediateActivity has leaked window DecorView@366e833[IntermediateActivity] that was originally added here
[WindowManager] at android.view.ViewRootImpl.<init>(ViewRootImpl.java:720)
[WindowManager] at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:399)
[WindowManager] at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:109)
[WindowManager] at android.app.Dialog.show(Dialog.java:340)
[WindowManager] at mono.java.lang.RunnableImplementor.n_run(Native Method)
[WindowManager] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Run08-18 14:02:33.193 E/WindowManager(17196): at android.app.Activity.runOnUiThread(Activity.java:7062)
[WindowManager] at mono.java.lang.RunnableImplementor.n_run(Native Method)
[WindowManager] at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
[WindowManager] at android.os.Handler.handleCallback(Handler.java:938)
[WindowManager] at android.os.Handler.dispatchMessage(Handler.java:99)
[WindowManager] at android.os.Looper.loop(Looper.java:223)
[WindowManager] at android.app.ActivityThread.main(ActivityThread.java:7664)
[WindowManager] at java.lang.reflect.Method.invoke(Native Method)
[WindowManager] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
It seems PickPhotoAsync
and related methods return too early when IntermediateActivity isn't fully finished yet. As a result UserDialogs tries to show a fragment using IntermediateActivity context which causes this crash.
For now I've added a timeout after receiving the media result:
var taken = await _media.CapturePhotoAsync();
if (taken == null)
{
return null;
}
static bool _IsIntermediateActivity()
{
Activity activity = Xamarin.Essentials.Platform.CurrentActivity;
return activity.GetType().Name == "IntermediateActivity";
}
while (_IsIntermediateActivity())
{
await Task.Delay(10);
}
return taken;
@jamesmontemagno sorry for not replying earlier.
A lot has been changed/ updated since I tried updating to this NuGet. When I get time to look at this again (probably towards the end of this year), then I'll update this issue with a repo (if it's still happening)
Thanks, @lassana your workaround works
@jamesmontemagno here is a repo that recreates the issue + shows it working with the workaround - MediaIssueRepo.zip
It seems
PickPhotoAsync
and related methods return too early when IntermediateActivity isn't fully finished yet. As a result UserDialogs tries to show a fragment using IntermediateActivity context which causes this crash.
Yes, we encountered a similar bug: the confirm dialog from the Acr.UserDialogs
is not shown if it is requested immediately after the CapturePhotoAsync
returns. It is caused exactly because CapturePhotoAsync
returns directly from the OnActivityResult
of the IntermediateActivity
and this is not compatible with the way the Acr.UserDialogs
works.
It seems
PickPhotoAsync
and related methods return too early when IntermediateActivity isn't fully finished yet. As a result UserDialogs tries to show a fragment using IntermediateActivity context which causes this crash.For now I've added a timeout after receiving the media result:
var taken = await _media.CapturePhotoAsync(); if (taken == null) { return null; } static bool _IsIntermediateActivity() { Activity activity = Xamarin.Essentials.Platform.CurrentActivity; return activity.GetType().Name == "IntermediateActivity"; } while (_IsIntermediateActivity()) { await Task.Delay(10); } return taken;
Thanks! This got me on the right track. I had to add a delay after picking a photo to be able to push a new page on the Navigation stack.
Would calling Finish()
before returning the result to the task fix the issue? https://github.com/xamarin/Essentials/blob/main/Xamarin.Essentials/Platform/Platform.android.cs#L381-L411
Thanks, @lassana your workaround works
@jamesmontemagno here is a repo that recreates the issue + shows it working with the workaround - MediaIssueRepo.zip
How would this work if you are working on ViewModels. Is there a way to call Xamarin.Essentials.Platform.CurrentActivity inside Viewmodel classes?