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

Assertion failed: (!scaled_font->cache_frozen), function _cairo_scaled_glyph_page_destroy, file cairo-scaled-font.c, line 459. Abort trap: 6 #912

Open
matty22 opened this issue May 1, 2017 · 15 comments
Labels

Comments

@matty22
Copy link

matty22 commented May 1, 2017

Issue

I seem to be hitting a bug when using ctx.fillText. In the code sample below, I can do ctx.fillRect fine and do get a rectangle output with the correct color and dimensions, but the text string errs. If I comment out the ctx.fillText("Hello World", 100, 100); line, the canvas builds the image as expected. Obviously, I'd like to stick some text on top of the canvas before the image file is generated, but .fillText gives the following error:

Assertion failed: (!scaled_font->cache_frozen), function _cairo_scaled_glyph_page_destroy, file cairo-scaled-font.c, line 459. Abort trap: 6

Steps to Reproduce

// Paint bg
  ctx.fillStyle = bgcolor;
  ctx.fillRect(0, 0, width, height);
  
  // Paint text
  ctx.font = '30px Arial';
  ctx.textAlign = 'center';
  ctx.textBaseline = 'middle';
  ctx.fillStyle = color;
  // If I comment this fillText line, no error appears in console
  ctx.fillText("Hello World", 100, 100);

Your Environment

  • Version of node-canvas: 1.6.5
  • Environment: node v7.8.0 on Mac OSX Sierra 10.12.4
@matty22
Copy link
Author

matty22 commented May 1, 2017

I have since tried a few things that looked like possible solutions around the web.

I tried opening FontBook on my Mac and validating all of the fonts and double checked that the fonts I am trying to use to fillText exist on my system. They do and are all now validated. No change in error message.

Seems to be a not uncommon issue related to using Cairo. Here are posts in other places about this same issue, but using different technologies on top of Cairo:

When using ImageMagick: http://www.imagemagick.org/discourse-server/viewtopic.php?t=31736
Similar issue when using Ruby: andymeneely/squib#193
Similar issue reported on Linux forum: http://linuxbbq.org/bbs/viewtopic.php?f=6&t=2430
Similar issue regarding writing/reading Asian character fonts: https://bbs.archlinux.org/viewtopic.php?id=169075

I'm leaning toward this issue being caused by a bad font file or something in Cairo not installed correctly on my machine making Cairo unable to understand the font I am asking it to use to fillText()?

@matty22
Copy link
Author

matty22 commented May 1, 2017

Started digging through old closed issues on the repo and found in #837 that uninstalling Pango and doing a rebuild fixed someone else's issues with rendering text.

Ran
brew uninstall pango
npm rebuild canvas

Now I am no longer getting the error: Assertion failed: (!scaled_font->cache_frozen), function _cairo_scaled_glyph_page_destroy, file cairo-scaled-font.c, line 459. Abort trap: 6

@chearon
Copy link
Collaborator

chearon commented May 1, 2017

Uninstalling Pango and rebuilding would give you the non-pango build instead of the pango build, which are very different from each other (see #715).

Ideally you want the Pango build since it'll give you more features (more glyphs, languages, etc). I have never seen an error like that though so I don't know if I can help. If you really want to narrow down the issue you could start with a minimal Pango+Cairo program in C.

@zbjornson zbjornson added the Bug label Nov 5, 2017
@LucidityDesign
Copy link

Any updates on this?

@chearon
Copy link
Collaborator

chearon commented Nov 15, 2017

I think this was an issue in the Cairo font system, which we don't use anymore (try it with npm install canvas@next)

@LucidityDesign
Copy link

LucidityDesign commented Nov 16, 2017

No, still the same error with canvas@2.0.0-alpha.6.

@LucidityDesign
Copy link

After reinstalling the brew packages and with canvas@2.0.0-alpha.8 the error is gone

@itsjakeb
Copy link

I am still experiencing this problem.

@jbeuckm
Copy link

jbeuckm commented Feb 2, 2018

I still have this with canvas@2.0.0-alpha.8

@ophinjay
Copy link

ophinjay commented Aug 3, 2018

I was using canvas@2.0.0-alpha.12 and it was working fine... but after I upgraded to canvas@2.0.0-alpha.13 I'm getting this issue

@zbjornson
Copy link
Collaborator

@ophinjay were you using a prebuilt .12 and a from-source-build of .13? What platform?

@ophinjay
Copy link

ophinjay commented Aug 4, 2018

@zbjornson No it was prebuilt version of .13 not compiled from source... did npm install canvas2.0.0-alpha.13.. that is the prebuit version right... I'm on MacOS.. I also tried uninstalling all the dependencies pkg-config cairo pango libpng jpeg giflib and reinstalled them... still the same... When I revert to .12, everything works

@zbjornson
Copy link
Collaborator

@ophinjay there's no prebuilt version of .13 yet (releases listed here), so my question should have just been "are you using prebuilt .12 or building from source?"

I'm not sure about the MacOS situation, but prebuilt .12 may have come with a newer version of pango than the one you have locally that was used when building .13 from source.

@FerdinandFidel
Copy link

Get always the same issue - Assertion failed: (!scaled_font->cache_frozen), function _cairo_scaled_glyph_page_destroy, file cairo-scaled-font.c, line 459.
Abort trap: 6

I try to load manually the font and this:https://medium.com/@adamhooper/fonts-in-node-canvas-bbf0b6b0cabf, but get the issue too.
My set up: Mac OS 10.13.6, canvas@^2.0.0-alpha.17 and installed the packages via brew install pkg-config cairo pango libpng jpeg giflib librsvg.

When i uninstall pango, nothing works.
What going wrong there ? Maybe someone has some hint ?

@FerdinandFidel
Copy link

FerdinandFidel commented Nov 3, 2018

When I use canvas-prebuilt it works for me. Find the solution here: #837

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants