Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SKPathEffect.Create2DLine Crashes on Android Emulators #142

Closed
ollira opened this issue Aug 22, 2016 · 2 comments
Closed

SKPathEffect.Create2DLine Crashes on Android Emulators #142

ollira opened this issue Aug 22, 2016 · 2 comments
Milestone

Comments

@ollira
Copy link

ollira commented Aug 22, 2016

My Android emulators appear to have some problem with SKPathEffect.Create2DLine method on version 1.53.1.1. Is this a known issue?

Regards,
Olli Raisa

Sample code:

    // OR: v1.53.1.1 crashes on Android emulators, OK on Windows
    public static void PathEffect2DLine(SKCanvas canvas, int width, int height)
    {
        float margin = Math.Min(width, height) / 5f;
        float scale = 10.0f;

        canvas.Clear(SKColors.White);

        using (var paint = new SKPaint())
        using (var effect = SKPathEffect.Create2DLine(1f, SKMatrix.MakeScale(scale, scale)))
        {
            paint.PathEffect = effect;
            canvas.DrawRect(new SKRect(margin, margin, width - margin, height - margin), paint);
        }
    }

Output from Visual Studio 2015 (Update 3):

08-22 02:35:33.270 E/mono-rt ( 2454): Stacktrace:
08-22 02:35:33.270 E/mono-rt ( 2454):
08-22 02:35:33.270 E/mono-rt ( 2454): at <0xffffffff>
08-22 02:35:33.270 E/mono-rt ( 2454): at (wrapper managed-to-native) SkiaSharp.SkiaApi.sk_path_effect_create_2d_line (single,SkiaSharp.SKMatrix) <0x00015>
08-22 02:35:33.270 E/mono-rt ( 2454): at SkiaSharp.SKPathEffect.Create2DLine (single,SkiaSharp.SKMatrix) <IL 0x00002, 0x000a7>
08-22 02:35:33.270 E/mono-rt ( 2454): at SkiaSharp.Demos.PathEffect2DLine (SkiaSharp.SKCanvas,int,int) [0x00028] in D:\src\SkiaSharp\samples\SharedDemo\SkiaSharp.Demos.cs:1038
08-22 02:35:33.270 E/mono-rt ( 2454): at Skia.Forms.Demo.SkiaView.Draw (SkiaSharp.SKCanvas) [0x00001] in D:\src\SkiaSharp\samples\Skia.Forms.Demo\SkiaView.cs:28
08-22 02:35:33.270 E/mono-rt ( 2454): at Skia.Forms.Demo.SkiaView.Skia.Forms.Demo.ISkiaViewController.SendDraw (SkiaSharp.SKCanvas) [0x00001] in D:\src\SkiaSharp\samples\Skia.Forms.Demo\SkiaView.cs:18
08-22 02:35:33.270 E/mono-rt ( 2454): at Skia.Forms.Demo.Droid.NativeSkiaView.OnDraw (Android.Graphics.Canvas) [0x000dc] in D:\src\SkiaSharp\samples\Skia.Forms.Demo\Droid\NativeSkiaView.cs:37
08-22 02:35:33.270 E/mono-rt ( 2454): at Android.Views.View.n_OnDraw_Landroid_graphics_Canvas_ (intptr,intptr,intptr) [0x00011] in /Users/builder/data/lanes/3540/1cf254db/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.View.cs:14205
08-22 02:35:33.270 E/mono-rt ( 2454): at (wrapper dynamic-method) object.b284673e-3f63-410e-9c6d-14aa958db100 (intptr,intptr,intptr) <IL 0x00017, 0x00027>
08-22 02:35:33.270 E/mono-rt ( 2454): at (wrapper native-to-managed) object.b284673e-3f63-410e-9c6d-14aa958db100 (intptr,intptr,intptr) <IL 0x0001f, 0x0007b>
08-22 02:35:33.270 E/mono-rt ( 2454):
08-22 02:35:33.270 E/mono-rt ( 2454): Attempting native Android stacktrace:
08-22 02:35:33.270 E/mono-rt ( 2454):
08-22 02:35:33.280 E/mono-rt ( 2454): at sk_path_effect_create_2d_line+25 [0x9646cf79]
08-22 02:35:33.280 E/mono-rt ( 2454): at ???+61095 [0x962f9ea7]
08-22 02:35:33.280 E/mono-rt ( 2454): at ???+59295 [0x962f979f]
08-22 02:35:33.280 E/mono-rt ( 2454): at ???+39681 [0x9718fb01]
08-22 02:35:33.280 E/mono-rt ( 2454): at ???+39352 [0x9718f9b8]
08-22 02:35:33.280 E/mono-rt ( 2454): at ???+18237 [0x9718a73d]
08-22 02:35:33.280 E/mono-rt ( 2454): at ???+10934 [0x97188ab6]
08-22 02:35:33.280 E/mono-rt ( 2454): at ???+9103 [0x97d1e38f]
08-22 02:35:33.280 E/mono-rt ( 2454): at ???+23819 [0x9765dd0b]
08-22 02:35:33.280 E/mono-rt ( 2454): at dvmPlatformInvoke+79 [0xb4cc80eb]
08-22 02:35:33.280 E/mono-rt ( 2454): at dvmCallJNIMethod(unsigned int const_, JValue_, Method const_, Thread_)+285 [0xb4d2489d]
08-22 02:35:33.280 E/mono-rt ( 2454): at ???+257 [0x101]
08-22 02:35:33.280 E/mono-rt ( 2454):
08-22 02:35:33.280 E/mono-rt ( 2454): =================================================================
08-22 02:35:33.280 E/mono-rt ( 2454): Got a SIGSEGV while executing native code. This usually indicates
08-22 02:35:33.280 E/mono-rt ( 2454): a fatal error in the mono runtime or one of the native libraries
08-22 02:35:33.280 E/mono-rt ( 2454): used by your application.
08-22 02:35:33.280 E/mono-rt ( 2454): =================================================================
08-22 02:35:33.280 E/mono-rt ( 2454):
08-22 02:35:33.280 F/libc ( 2454): Fatal signal 11 (SIGSEGV) at 0x41200000 (code=1), thread 2454 (skia_forms_demo)

@ollira
Copy link
Author

ollira commented Aug 23, 2016

The same thing happens also in SKPathEffect.Create2DPath

Code sample

    public static void PathEffect2DPath(SKCanvas canvas, int width, int height)
    {
        float margin = Math.Min(width, height) / 5f;
        float scale = 30f;

        canvas.Clear(SKColors.White);

        SKPath path = new SKPath();
        path.AddCircle(0, 0, scale/3f, SKPathDirection.Clockwise);

        using (var paint = new SKPaint())
        using (var effect = SKPathEffect.Create2DPath(SKMatrix.MakeScale(scale, scale), path))
        {
            paint.PathEffect = effect;
            canvas.DrawRect(new SKRect(margin, margin, width - margin, height - margin), paint);
        }
    }

The respective C functions expect pointers to matrix data:

SK_API sk_path_effect_t* sk_path_effect_create_2d_line(float width, const sk_matrix_t* matrix);
SK_API sk_path_effect_t* sk_path_effect_create_2d_path(const sk_matrix_t* matrix, const sk_path_t* path);

SkiaSharp uses SKMatrix as the parameter type:

    [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
    public extern static sk_path_effect_t sk_path_effect_create_2d_line(float width, SKMatrix matrix);
    [DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
    public extern static sk_path_effect_t sk_path_effect_create_2d_path(SKMatrix matrix, sk_path_t path);

Perhaps a matrix reference is needed here.

Regards,
Olli Raisa

@mattleibow mattleibow added this to the 1.53.1.2 milestone Aug 23, 2016
@mattleibow
Copy link
Contributor

Hi @ollira Thanks for reporting and taking the time to have a poke around in the code.
Your suggestion was correct, we were not marshalling the struct properly.

@ghost ghost locked as resolved and limited conversation to collaborators Aug 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants