Is there any way to clear canvas from outside of the PaintSurface event?

LightLight Member ✭✭

Is there any way to make changes to canvas from outside of the PaintSurface event? I want to use e.Surface.Canvas.Clear() in method ClearButton_Clicked(object sender, EventArgs e),but I can't understand how to pass SKPaintSurfaceEventArgs to this method. Can someone give me advice on this? Thank you.

Answers

  • suraj007suraj007 Member ✭✭✭

    e.Surface.Canvas.Clear()
    this "e" save in globally.
    like this

    SKPaintSurfaceEventArgs test; \declared globally

    //////////////////////////////////////////***********************//////////////////////////////////

    protected override void OnPaintSurface (SKPaintSurfaceEventArgs e)
    {
    test=e;\save e
    }

    //////////////////////////////////////////***********************//////////////////////////////////

    //////////////////////////////////////////***********************//////////////////////////////////

    ClearButton_Clicked(object sender, EventArgs e)

    {

    test.Surface.Canvas.Clear()

    }

    //////////////////////////////////////////***********************//////////////////////////////////

    Thank you.

  • LightLight Member ✭✭

    @suraj007 said:
    e.Surface.Canvas.Clear()
    this "e" save in globally.
    like this

    SKPaintSurfaceEventArgs test; \declared globally

    //////////////////////////////////////////***********************//////////////////////////////////

    protected override void OnPaintSurface (SKPaintSurfaceEventArgs e)
    {
    test=e;\save e
    }

    //////////////////////////////////////////***********************//////////////////////////////////

    //////////////////////////////////////////***********************//////////////////////////////////

    ClearButton_Clicked(object sender, EventArgs e)

    {

    test.Surface.Canvas.Clear()

    }

    //////////////////////////////////////////***********************//////////////////////////////////

    Thank you.

    Thank you for help, but program crashes if I try to use code from your answer.

  • suraj007suraj007 Member ✭✭✭

    what is the error?

  • LightLight Member ✭✭

    @suraj007 said:
    what is the error?

    There is a lot of info about this problem in logs, I can't say for sure what info you need so I copied all logs here.

    Got a SIGSEGV while executing native code. This usually indicates
    a fatal error in the mono runtime or one of the native libraries
    used by your application.

    =================================================================

    Basic Fault Adddress Reporting

    Memory around native instruction pointer (0x70dacf3430):0x70dacf3420 c0 03 5f d6 f3 0f 1e f8 fd 7b 01 a9 f3 03 00 aa
    0x70dacf3430 60 12 40 f9 fd 43 00 91 00 02 00 b5 68 02 40 f9 [email protected]@. 0x70dacf3440 e0 03 13 aa 08 15 40 f9 00 01 3f d6 68 12 40 f9 [email protected][email protected] 0x70dacf3450 60 12 00 f9 c8 00 00 b4 09 01 40 f9 e0 03 08 aa[email protected]

    No native Android stacktrace (see debuggerd output).

    ==================

    Managed Stacktrace:

    at <0xffffffff>
    at SkiaSharp.SkiaApi:sk_surface_get_canvas <0x00007>
    at SkiaSharp.SKSurface:get_Canvas <0x00097>
    at App17.MainPage:Two_Clicked <0x000c3>
    at Xamarin.Forms.Button:Xamarin.Forms.Internals.IButtonElement.PropagateUpClicked <0x000cf>
    at Xamarin.Forms.ButtonElement:ElementClicked <0x001cf>
    at Xamarin.Forms.Button:SendClicked <0x00073>
    at Xamarin.Forms.Platform.Android.ButtonElementManager:OnClick <0x000ab>
    at Xamarin.Forms.Platform.Android.FastRenderers.ButtonRenderer:Android.Views.View.IOnClickListener.OnClick <0x000a3>
    at IOnClickListenerInvoker:n_OnClick_Landroid_view_View_ <0x0011b>
    at Android.Runtime.DynamicMethodNameCounter:47 <0x0003f>
    at Android.Runtime.DynamicMethodNameCounter:47 <0x000cb>
    =================================================================08-29 17:11:10.117 E/mono-rt (16670): 12c00000-32c00000 rw-p 00000000 00:05 33655 /dev/ashmem/dalvik-main space (region space)_993_993 (deleted)

    08-29 17:11:10.117 E/mono-rt (16670): 6f46a000-6f745000 rw-p 00000000 fe:03 74 /data/dalvik-cache/arm64/[email protected]@boot.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f745000-6f75b000 r--p 002db000 fe:03 74 /data/dalvik-cache/arm64/[email protected]@boot.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f75b000-6f890000 rw-p 00000000 fe:03 83 /data/dalvik-cache/arm64/[email protected]@boot-core-libart.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f890000-6f8a2000 r--p 00135000 fe:03 83 /data/dalvik-cache/arm64/[email protected]@boot-core-libart.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f8a2000-6f8e2000 rw-p 00000000 fe:03 91 /data/dalvik-cache/arm64/[email protected]@boot-conscrypt.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f8e2000-6f8e5000 r--p 00040000 fe:03 91 /data/dalvik-cache/arm64/[email protected]@boot-conscrypt.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f8e5000-6f92c000 rw-p 00000000 fe:03 94 /data/dalvik-cache/arm64/[email protected]@boot-okhttp.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f92c000-6f930000 r--p 00047000 fe:03 94 /data/dalvik-cache/arm64/[email protected]@boot-okhttp.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f930000-6f996000 rw-p 00000000 fe:03 103 /data/dalvik-cache/arm64/[email protected]@boot-bouncycastle.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f996000-6f99d000 r--p 00066000 fe:03 103 /data/dalvik-cache/arm64/[email protected]@boot-bouncycastle.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f99d000-6f9fe000 rw-p 00000000 fe:03 106 /data/dalvik-cache/arm64/[email protected]@boot-apache-xml.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f9fe000-6fa05000 r--p 00061000 fe:03 106 /data/dalvik-cache/arm64/[email protected]@boot-apache-xml.art
    08-29 17:11:10.117 E/mono-rt (16670): 6fa05000-6fa49000 rw-p 00000000 fe:03 113 /data/dalvik-cache/arm64/[email protected]@boot-ext.art
    08-29 17:11:10.117 E/mono-rt (16670): 6fa49000-6fa54000 r--p 00044000 fe:03 113 /data/dalvik-cache/arm64/[email protected]@boot-ext.art
    08-29 17:11:10.117 E/mono-rt (16670): 6fa54000-70661000 rw-p 00000000 fe:03 132 /data/dalvik-cache/arm64/[email protected]@boot-framework.art
    08-29 17:11:10.117 E/mono-rt (16670): 70661000-706c1000 r--p 00c0d000 fe:03 132 /data/dalvik-cache/arm64/[email protected]@boot-framework.art
    08-29 17:11:10.117 E/mono-rt (16670): 706c1000-7084a000 rw-p 00000000 fe:03 145 /data/dalvik-cache/arm64/[email protected]@boot-telephony-common.art
    08-29 17:11:10.117 E/mono-rt (16670): 7084a000-70868000 r--p 00189000 fe:03 145 /data/dalvik-cache/arm64/[email protected]@boot-telephony-common.art
    08-29 17:11:10.117 E/mono-rt (16670): 70868000-70877000 rw-p 00000000 fe:03 153 /data/dalvik-cache/arm64/[email protected]@boot-voip-common.art
    08-29 17:11:10.117 E/mono-rt (16670): 70877000-70879000 r--p 0000f000 fe:03 153 /data/dalvik-cache/arm64/[email protected]@boot-voip-common.art
    08-29 17:11:10.117 E/mono-rt (16670): 70879000-70896000 rw-p 00000000 fe:03 161 /data/dalvik-cache/arm64/[email protected]@boot-ims-common.art
    08-29 17:11:10.117 E/mono-rt (16670): 70896000-70898000 r--p 0001d000 fe:03 161 /data/dalvik-cache/arm64/[email protected]@boot-ims-common.art
    08-29 17:11:10.117 E/mono-rt (16670): 70898000-708a1000 rw-p 00000000 fe:03 167 /data/dalvik-cache/arm64/[email protected]@boot-sprengine.art
    08-29 17:11:10.117 E/mono-rt (16670): 708a1000-708a3000 rw-p 00000000 fe:03 173 /data/dalvik-cache/arm64/[email protected]@boot-android.hidl.base-V1.0-java.art
    08-29 17:11:10.119 F/libc (16670): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x20 in tid 16670 (mpanyname.app17), pid 16670 (mpanyname.app17)

    In case if you don't want to look at logs, the last line is

    Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x20 in tid 16670 (mpanyname.app17), pid
    16670panyname.app17)

    So I think that is the error.

  • LightLight Member ✭✭

    @suraj007 said:
    what is the error?

    There is a lot of info about this problem in logs, I can't say for sure what info you need so I copied all logs here.

    Got a SIGSEGV while executing native code. This usually indicates
    a fatal error in the mono runtime or one of the native libraries
    used by your application.

    =================================================================

    Basic Fault Adddress Reporting

    Memory around native instruction pointer (0x70dacf3430):0x70dacf3420 c0 03 5f d6 f3 0f 1e f8 fd 7b 01 a9 f3 03 00 aa
    0x70dacf3430 60 12 40 f9 fd 43 00 91 00 02 00 b5 68 02 40 f9 [email protected]@. 0x70dacf3440 e0 03 13 aa 08 15 40 f9 00 01 3f d6 68 12 40 f9 [email protected][email protected] 0x70dacf3450 60 12 00 f9 c8 00 00 b4 09 01 40 f9 e0 03 08 aa[email protected]

    No native Android stacktrace (see debuggerd output).

    ==================

    Managed Stacktrace:

    at <0xffffffff>
    at SkiaSharp.SkiaApi:sk_surface_get_canvas <0x00007>
    at SkiaSharp.SKSurface:get_Canvas <0x00097>
    at App17.MainPage:Two_Clicked <0x000c3>
    at Xamarin.Forms.Button:Xamarin.Forms.Internals.IButtonElement.PropagateUpClicked <0x000cf>
    at Xamarin.Forms.ButtonElement:ElementClicked <0x001cf>
    at Xamarin.Forms.Button:SendClicked <0x00073>
    at Xamarin.Forms.Platform.Android.ButtonElementManager:OnClick <0x000ab>
    at Xamarin.Forms.Platform.Android.FastRenderers.ButtonRenderer:Android.Views.View.IOnClickListener.OnClick <0x000a3>
    at IOnClickListenerInvoker:n_OnClick_Landroid_view_View_ <0x0011b>
    at Android.Runtime.DynamicMethodNameCounter:47 <0x0003f>
    at Android.Runtime.DynamicMethodNameCounter:47 <0x000cb>
    =================================================================08-29 17:11:10.117 E/mono-rt (16670): 12c00000-32c00000 rw-p 00000000 00:05 33655 /dev/ashmem/dalvik-main space (region space)_993_993 (deleted)

    08-29 17:11:10.117 E/mono-rt (16670): 6f46a000-6f745000 rw-p 00000000 fe:03 74 /data/dalvik-cache/arm64/[email protected]@boot.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f745000-6f75b000 r--p 002db000 fe:03 74 /data/dalvik-cache/arm64/[email protected]@boot.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f75b000-6f890000 rw-p 00000000 fe:03 83 /data/dalvik-cache/arm64/[email protected]@boot-core-libart.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f890000-6f8a2000 r--p 00135000 fe:03 83 /data/dalvik-cache/arm64/[email protected]@boot-core-libart.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f8a2000-6f8e2000 rw-p 00000000 fe:03 91 /data/dalvik-cache/arm64/[email protected]@boot-conscrypt.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f8e2000-6f8e5000 r--p 00040000 fe:03 91 /data/dalvik-cache/arm64/[email protected]@boot-conscrypt.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f8e5000-6f92c000 rw-p 00000000 fe:03 94 /data/dalvik-cache/arm64/[email protected]@boot-okhttp.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f92c000-6f930000 r--p 00047000 fe:03 94 /data/dalvik-cache/arm64/[email protected]@boot-okhttp.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f930000-6f996000 rw-p 00000000 fe:03 103 /data/dalvik-cache/arm64/[email protected]@boot-bouncycastle.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f996000-6f99d000 r--p 00066000 fe:03 103 /data/dalvik-cache/arm64/[email protected]@boot-bouncycastle.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f99d000-6f9fe000 rw-p 00000000 fe:03 106 /data/dalvik-cache/arm64/[email protected]@boot-apache-xml.art
    08-29 17:11:10.117 E/mono-rt (16670): 6f9fe000-6fa05000 r--p 00061000 fe:03 106 /data/dalvik-cache/arm64/[email protected]@boot-apache-xml.art
    08-29 17:11:10.117 E/mono-rt (16670): 6fa05000-6fa49000 rw-p 00000000 fe:03 113 /data/dalvik-cache/arm64/[email protected]@boot-ext.art
    08-29 17:11:10.117 E/mono-rt (16670): 6fa49000-6fa54000 r--p 00044000 fe:03 113 /data/dalvik-cache/arm64/[email protected]@boot-ext.art
    08-29 17:11:10.117 E/mono-rt (16670): 6fa54000-70661000 rw-p 00000000 fe:03 132 /data/dalvik-cache/arm64/[email protected]@boot-framework.art
    08-29 17:11:10.117 E/mono-rt (16670): 70661000-706c1000 r--p 00c0d000 fe:03 132 /data/dalvik-cache/arm64/[email protected]@boot-framework.art
    08-29 17:11:10.117 E/mono-rt (16670): 706c1000-7084a000 rw-p 00000000 fe:03 145 /data/dalvik-cache/arm64/[email protected]@boot-telephony-common.art
    08-29 17:11:10.117 E/mono-rt (16670): 7084a000-70868000 r--p 00189000 fe:03 145 /data/dalvik-cache/arm64/[email protected]@boot-telephony-common.art
    08-29 17:11:10.117 E/mono-rt (16670): 70868000-70877000 rw-p 00000000 fe:03 153 /data/dalvik-cache/arm64/[email protected]@boot-voip-common.art
    08-29 17:11:10.117 E/mono-rt (16670): 70877000-70879000 r--p 0000f000 fe:03 153 /data/dalvik-cache/arm64/[email protected]@boot-voip-common.art
    08-29 17:11:10.117 E/mono-rt (16670): 70879000-70896000 rw-p 00000000 fe:03 161 /data/dalvik-cache/arm64/[email protected]@boot-ims-common.art
    08-29 17:11:10.117 E/mono-rt (16670): 70896000-70898000 r--p 0001d000 fe:03 161 /data/dalvik-cache/arm64/[email protected]@boot-ims-common.art
    08-29 17:11:10.117 E/mono-rt (16670): 70898000-708a1000 rw-p 00000000 fe:03 167 /data/dalvik-cache/arm64/[email protected]@boot-sprengine.art
    08-29 17:11:10.117 E/mono-rt (16670): 708a1000-708a3000 rw-p 00000000 fe:03 173 /data/dalvik-cache/arm64/[email protected]@boot-android.hidl.base-V1.0-java.art
    08-29 17:11:10.119 F/libc (16670): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x20 in tid 16670 (mpanyname.app17), pid 16670 (mpanyname.app17)

    In case if you don't want to look at logs, the last line is

    Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x20 in tid 16670 (mpanyname.app17), pid
    16670panyname.app17)

    So I think that is the error.

Sign In or Register to comment.