Xamarin mediaPicker.TakePhotoAsync crashes activity

I have an Xamarin.Forms app that uses XLabs, it was working fine, but suddenly it started to crash my app, if I take photo or press back button from photo screen, I was googling around for 4 hours and still have no idea why it happening, any ideas or thoughts, please help!

here is my lines of code:

        private async Task TakePicture()
        {
            mediaPicker = Resolver.Resolve<IDevice>().MediaPicker;

            try
            {
                var mediaFile = await mediaPicker.TakePhotoAsync(new CameraMediaStorageOptions
                {
                    DefaultCamera = CameraDevice.Front,
                    MaxPixelDimension = 1,
                    PercentQuality = 2,
                });

                var image = GetResizedImage(mediaFile.Source, 990, 560);
                OnImageUpdate(this, image);
            }
            catch (Exception ex)
            {
                this.status = ex.Message;
            }
        }

my permission are alright:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.CAMERA" />

unfortunately stacktrace is quiet:

    07-02 12:23:51.188 D/AbsListView(27740): Get MotionRecognitionManager
    07-02 12:23:51.358 D/dalvikvm(27740): GC_FOR_ALLOC freed 5784K, 42% free 11103K/18836K, paused 16ms, total 16ms
    07-02 12:23:51.798 D/LocationHandler(27740): logged location changed: Location[fused 55.545240,37.561890 acc=10 et=+2d23h12m54s153ms]
    07-02 12:23:51.823 D/dalvikvm(27740): GC_FOR_ALLOC freed 272K, 38% free 11706K/18836K, paused 25ms, total 25ms
    07-02 12:23:51.833 I/dalvikvm-heap(27740): Grow heap (frag case) to 14.620MB for 2217616-byte allocation
    07-02 12:23:51.858 D/dalvikvm(27740): GC_FOR_ALLOC freed <1K, 34% free 13872K/21004K, paused 23ms, total 23ms
    07-02 12:23:51.863 I/dalvikvm-heap(27740): Grow heap (frag case) to 16.735MB for 2217616-byte allocation
    07-02 12:23:51.888 D/dalvikvm(27740): GC_FOR_ALLOC freed 0K, 31% free 16037K/23172K, paused 21ms, total 21ms
    07-02 12:23:52.033 V/RenderScript(27740): 0x77dee038 Launching thread(s), CPUs 8
    07-02 12:23:52.123 D/dalvikvm(27740): GC_CONCURRENT freed 48K, 22% free 19473K/24900K, paused 3ms+3ms, total 28ms
    07-02 12:23:52.123 D/dalvikvm(27740): WAIT_FOR_CONCURRENT_GC blocked 18ms
    07-02 12:23:52.138 D/dalvikvm(27740): GC_FOR_ALLOC freed <1K, 22% free 19473K/24900K, paused 17ms, total 17ms
    07-02 12:23:56.073 D/ProgressBar(27740): updateDrawableBounds: left = 0
    07-02 12:23:56.073 D/ProgressBar(27740): updateDrawableBounds: top = 0
    07-02 12:23:56.073 D/ProgressBar(27740): updateDrawableBounds: right = -2
    07-02 12:23:56.073 D/ProgressBar(27740): updateDrawableBounds: bottom = -2
    07-02 12:23:56.823 D/LocationHandler(27740): logged location changed:   Location[fused 55.545242,37.561899 acc=10 et=+2d23h12m59s210ms]
    07-02 12:23:57.958 D/Mono    (27740): Assembly Ref addref XLabs.Platform.Droid[0x771160e8] -> System[0x77d11670]: 14
    07-02 12:23:58.013 D/Activity(27740): #1 setTransGradationModeColor false
    07-02 12:23:58.073 D/Mono    (27740): Assembly Ref addref Xamarin.Forms.Platform.Android[0x7710be50] -> System.Xml[0x77cb0b80]: 6
    07-02 12:23:58.088 D/Mono    (27740): Assembly Ref addref System.Runtime.Serialization[0x791e9338] -> System[0x77d11670]: 15
    07-02 12:23:58.158 D/Mono    (27740): Assembly Ref addref System.Runtime.Serialization[0x791e9338] -> System.Core[0x779118c0]: 13
    07-02 12:23:58.303 D/AbsListView(27740): onDetachedFromWindow
    07-02 12:23:58.308 D/AbsListView(27740): onDetachedFromWindow
    07-02 12:24:01.888 D/LocationHandler(27740): logged location changed: Location[fused 55.545244,37.561902 acc=10 et=+2d23h13m4s294ms]
    07-02 12:24:05.498 D/Activity(27740): #1 setTransGradationModeColor false
    07-02 12:24:05.583 I/dalvikvm-heap(27740): Grow heap (frag case) to 25.216MB for 3385164-byte allocation
    07-02 12:24:05.673 I/dalvikvm-heap(27740): Grow heap (frag case) to 70.779MB for 47775760-byte allocation
    07-02 12:24:05.693 D/dalvikvm(27740): GC_CONCURRENT freed 11629K, 22% free 59749K/75984K, paused 4ms+3ms, total 22ms
    07-02 12:24:06.073 D/dalvikvm(27740): GC_EXPLICIT freed 7386K, 29% free 54536K/75984K, paused 1ms+2ms, total 17ms
    07-02 12:24:06.078 D/Mono    (27740): GC_OLD_BRIDGE num-objects 420 num_hash_entries 473 sccs size 468 init 0.00ms df1 0.86ms sort 0.09ms dfs2 0.44ms setup-cb 0.29ms free-data 0.73ms links 66/66/60/2 dfs passes 959/534
    07-02 12:24:06.078 D/Mono    (27740): GC_MAJOR: (LOS overflow) pause 18.03ms, total 18.25ms, bridge 28.50ms major 2224K/2032K los 3639K/17968K
    07-02 12:24:06.118 E/MoreInfoHPW_View(27740): Parent view is not a TextView
    07-02 12:24:06.163 D/ProgressBar(27740): updateDrawableBounds: left = 0
    07-02 12:24:06.163 D/ProgressBar(27740): updateDrawableBounds: top = 0
    07-02 12:24:06.168 D/ProgressBar(27740): updateDrawableBounds: right = -2
    07-02 12:24:06.168 D/ProgressBar(27740): updateDrawableBounds: bottom = -2
    07-02 12:24:06.178 D/ProgressBar(27740): updateDrawableBounds: left = 0
    07-02 12:24:06.178 D/ProgressBar(27740): updateDrawableBounds: top = 0
    07-02 12:24:06.178 D/ProgressBar(27740): updateDrawableBounds: right = -2
    07-02 12:24:06.178 D/ProgressBar(27740): updateDrawableBounds: bottom = -2
    07-02 12:24:06.188 D/Activity(27740): #3 setTransGradationModeColor to false
    07-02 12:24:06.233 D/ProgressBar(27740): updateDrawableBounds: left = 0
    07-02 12:24:06.233 D/ProgressBar(27740): updateDrawableBounds: top = 0
    07-02 12:24:06.233 D/ProgressBar(27740): updateDrawableBounds: right = 96
    07-02 12:24:06.233 D/ProgressBar(27740): updateDrawableBounds: bottom = 96
    07-02 12:24:06.233 W/View    (27740): requestLayout() improperly called by md5530bd51e982e6e7b340b73e88efe666e.PageRenderer{42545c40 V.E...C. ......ID 0,0-720,1134} during layout: running second layout pass
    07-02 12:24:06.233 W/View    (27740): requestLayout() improperly called by md5530bd51e982e6e7b340b73e88efe666e.ActivityIndicatorRenderer{42801f10 V.E..... ......ID 0,0--2,-2} during layout: running second layout pass
    07-02 12:24:06.233 W/View    (27740): requestLayout() improperly called by md5530bd51e982e6e7b340b73e88efe666e.RendererFactory_DefaultRenderer{427f9ce8 V.E...C. ......ID 0,0--2,-2} during layout: running second layout pass

so what happens is my MasterDetailPage recreates, because constructor of it called is calling again, but mediapicker is from another ContentPage, so I guess it 'drops' current activity and starts over, I still don't know why

Answers

Sign In or Register to comment.