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

SIGSEGV when using SKCanvas.DrawText() and then SKCanvas.Flush() #647

Closed
mattleibow opened this issue Sep 28, 2018 · 15 comments
Closed

SIGSEGV when using SKCanvas.DrawText() and then SKCanvas.Flush() #647

mattleibow opened this issue Sep 28, 2018 · 15 comments

Comments

@mattleibow
Copy link
Contributor

mattleibow commented Sep 28, 2018

Description

The app crashes when drawing text and then flushing the canvas. Waiting on a response from Google to address this.

Basic Information

  • Version with issue: 1.68.0
  • Last known good version: 1.60.3
  • IDE: N/A
  • Platform Target Frameworks:
    • Android: 8.1
  • Target Devices:
    • Pixel 2 and Razer Phone

Links

VS bug #736300

@mattleibow
Copy link
Contributor Author

mattleibow commented Oct 6, 2018

After doing some more research, I found out several things:

  • it works fine in the emulator
  • it works fine as a debug build

As a result, there appears to be something going wrong for ARM when the optimizations are at -Os. I had a try with -O3 and it appears to solve the issue.

However, this does incur a penalty with the size no longer being the main point. As a result, the size increases by about 800KB-1200KB depending on the architecture.

For this release, I will go with a larger binary that works over a smaller one that can't do GPU. I have reported the issue to Google along with all the information I could find. Hopefully, they can find out exactly what the issue is and provide a real fix.

@mattleibow mattleibow reopened this Oct 16, 2018
mattleibow added a commit that referenced this issue Oct 29, 2018
 - dotnet publish improvements #659
 - statically link vcredist #136
 - clang O3 optimization bug #647
@apaatsio
Copy link

I found this issue on google because I'm experiencing a similar bug on a Flutter app. See flutter/flutter#29751 and my comment

There seem to be many common denominators (Pixel 2, Android 8.1, drawing text, SIGSEGV during SKCanvas.Flush()) so I was wondering if these things could be related.

Unfortunately, I can't see the Skia issue 8425 that @mattleibow linked. It's giving me "Permission denied" so I can't dig deeper into this.

@blimkemann
Copy link

blimkemann commented Feb 7, 2020

I am getting this error even in debug builds using 1.68.0 and above when targeting Android 10 as a build target. It happens every time and is repeatable. If I remove all calls to DrawText there is no crash. Even a single DrawText will cause a crash with a "Could not allocate vertices" message.

Is there any news on this?

Here is the managed stack trace:

Memory around native instruction pointer (0x73a030012cfe):0x73a030012cee  48 89 74 24 48 ff 50 18 48 8b 8c 24 e8 00 00 00  H.t$H.P.H..$....
0x73a030012cfe  ff 41 08 48 89 44 24 28 48 8b 6c 24 60 48 89 4c  .A.H.D$(H.l$`H.L
0x73a030012d0e  24 60 48 85 ed 74 35 48 8d 5d 08 ff 4d 08 75 0d  $`H..t5H.]..M.u.
0x73a030012d1e  48 8d 7b f8 e8 d9 8c bf ff 84 c0 74 1f 83 7d 0c  H.{........t..}.

======================================
===========================
	Managed Stacktrace:
=================================================================
	  at <unknown> <0xffffffff>
	  at SkiaSharp.SkiaApi:sk_canvas_flush <0x0013f>
	  at SkiaSharp.SKCanvas:Flush <0x00097>
	  at Redbook.Mobile.Document.Renderer:RenderPage <0x0051b>
	  at Redbook.Mobile.Document.Page:Render <0x00113>
	  at <>c__DisplayClass27_0:<OnPaintSurface>b__0 <0x0172b>
	  at RunnableImplementor:Run <0x000d1>
	  at Java.Lang.IRunnableInvoker:n_Run <0x000db>
	  at Android.Runtime.DynamicMethodNameCounter:32 <0x0011a>
	  at Android.Runtime.DynamicMethodNameCounter:32 <0x000fa>
=================================================================

@mattleibow
Copy link
Contributor Author

@apaatsio, I had a look at that issue on the Google bug list, no feedback at all. The only comment a long while back was:

Well, it is dying while trying to upload glyphs to the font atlas.

I don't know why that would be occurring though.

@blimkemann could you create a test/repo project for your example. It was working when I reduced the optimization level a while back. Maybe this is a slightly different case that I can start testing on.

I am looking on getting a brand new skia engine out in #986, just trying to fix the last few bugs in the current version. Moving this issue to that release so it gets at least a test.

@blimkemann
Copy link

SkiaTextBug.zip
@mattleibow, here is a repro. Pretty simple really. Just start in debugger on Android and the drawing will crash as soon as Canvas.Flush is called. Please let me know if you have questions about this.

@mattleibow
Copy link
Contributor Author

Thanks! I'll have a look.

@mattleibow
Copy link
Contributor Author

This has been some time, I will try using the new v2.80 packages. Have you still been having this issue?

@blimkemann
Copy link

blimkemann commented Jun 26, 2020 via email

@mattleibow
Copy link
Contributor Author

Not sure how I missed it, but the issue with your code is that you are drawing outside of the main render loop.

This code:

MainThread.BeginInvokeOnMainThread(() => {
    // drawing code
});

The MainThread.BeginInvokeOnMainThread returns immediately and the surface/GL context is reset.

Just remove those blocks and draw directly.

@blimkemann
Copy link

blimkemann commented Jul 1, 2020 via email

@mattleibow
Copy link
Contributor Author

Are there any errors in the log? Is there something you are doing just before it happens?

@blimkemann
Copy link

blimkemann commented Jul 2, 2020 via email

@mattleibow
Copy link
Contributor Author

mattleibow commented Oct 13, 2020

@blimkemann Is this still happening? Have you tried the v2 of SkiaSharp?

@blimkemann
Copy link

blimkemann commented Oct 14, 2020 via email

@mattleibow
Copy link
Contributor Author

Thanks for the feedback. I'm closing it now. If things start happening, then feel free to open a new issue and link to this for context.

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

No branches or pull requests

4 participants