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

Built with QT 6.5.3 - crashes in libharfbuzz #23

Closed
quarcko opened this issue Jan 15, 2024 · 4 comments
Closed

Built with QT 6.5.3 - crashes in libharfbuzz #23

quarcko opened this issue Jan 15, 2024 · 4 comments

Comments

@quarcko
Copy link

quarcko commented Jan 15, 2024

Dear Webkit maintainers,

As we are moving towards updating QT Framework - and badly need webkit, we tried to build this repos branch "qt6"
using QT 6.5.3 version of Qt. so firstly few notes:

  1. We fixed all compilation errors for TOUCH and GESTURE_EVENTS
  2. QT6 OPENGL is undetectable - but we dont needed (info just in case it is important to this crash)
  3. There was a small fix inside Path.c where returning "platformPath" crashed inside QPainterPath constructor.

If needed i can upload all the fixes to you later on, but main problem is, that while trying to render page webkit crashes like this:

Thread 1 "QtTestBrowser" received signal SIGSEGV, Segmentation fault.

hb_blob_ptr_t<OT::GSUB>::get (this=<optimized out>) at ../../src/hb-blob.hh:88 88 ../../src/hb-blob.hh: No such file or directory.

#1 hb_blob_ptr_t<OT::GSUB>::operator* (this=<optimized out>) at ../../src/hb-blob.hh:85 85 in ../../src/hb-blob.hh

#2 get_gsubgpos_table (face=0x7fffe8fc7560 <_hb_Null_hb_font_t>, table_tag=<optimized out>) at ../../src/hb-ot-layout.cc:403 403 ../../src/hb-ot-layout.cc: No such file or directory.

#3 0x00007fffe75869b9 in hb_ot_layout_table_find_feature_variations (face=<optimized out>, table_tag=<optimized out>, coords=0x3ed0000080000000, num_coords=0, variations_index=0x555555922c14) at ../../src/hb-ot-layout.cc:1262 1262 in ../../src/hb-ot-layout.cc

#4 0x00007fffe75b529a in hb_ot_shape_plan_key_t::init (num_coords=0, coords=0x3ed0000080000000, face=0x7fffe8fc7560 <_hb_Null_hb_font_t>, this=0x555555922c14) at ../../src/hb-ot-shape.hh:45 45 ../../src/hb-ot-shape.hh: No such file or directory.

#5 hb_shape_plan_key_t::init (this=this@entry=0x555555922be8, copy=copy@entry=true, face=face@entry=0x7fffe8fc7560 <_hb_Null_hb_font_t>, props=props@entry=0x555555922aa8, user_features=user_features@entry=0x0, num_user_features=num_user_features@entry=0, coords=0x3ed0000080000000, num_coords=0, shaper_list=0x0) at ../../src/hb-shape-plan.cc:90 90 ../../src/hb-shape-plan.cc: No such file or directory.

#6 0x00007fffe75b57a2 in hb_shape_plan_create2 (face=face@entry=0x7fffe8fc7560 <_hb_Null_hb_font_t>, props=props@entry=0x555555922aa8, user_features=user_features@entry=0x0, num_user_features=num_user_features@entry=0, coords=coords@entry=0x3ed0000080000000, num_coords=num_coords@entry=0, shaper_list=<optimized out>) at ../../src/hb-shape-plan.cc:248 248 in ../../src/hb-shape-plan.cc

#7 0x00007fffe75b94a4 in hb_shape_plan_create_cached2 (face=0x7fffe8fc7560 <_hb_Null_hb_font_t>, props=props@entry=0x555555922aa8, user_features=user_features@entry=0x0, num_user_features=num_user_features@entry=0, coords=0x3ed0000080000000, num_coords=0, shaper_list=<optimized out>) at ../../src/hb-shape-plan.cc:555 555 in ../../src/hb-shape-plan.cc

#8 0x00007fffe75b9522 in hb_shape_full (font=0x555555731f50, buffer=0x555555922a70, features=0x0, num_features=0, shaper_list=<optimized out>) at ../../src/hb-shape.cc:135 135 ../../src/hb-shape.cc: No such file or directory.

#9 0x00007fffed5a3cc6 in WebCore::ComplexTextController::collectComplexTextRunsForCharacters (this=0x7fffffff70d0, characters=0x7fffda5034d4 u"Gmail", length=5, stringLocation=0, font=0x7fffda270680) at /program_files/webkit-qt6/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp:435 435 hb_shape(harfBuzzFont.get(), buffer.get(), nullptr, 0);

Also, enabled qDEBUG (that was put by someone of you):

void WebCore::ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned int, unsigned int, const WebCore::Font*) 400 0x555555709050 4 void WebCore::ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned int, unsigned int, const WebCore::Font*) 402 hb_qt_font_get_for_engine 0x555555731f50 void WebCore::ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned int, unsigned int, const WebCore::Font*) 403 0x7fffe8fc7560 void WebCore::ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned int, unsigned int, const WebCore::Font*) 405 0x555555a9d0c0 void WebCore::ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned int, unsigned int, const WebCore::Font*) 406 hb_qt_face_get_for_engine 0x555555a9d0c0 void WebCore::ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned int, unsigned int, const WebCore::Font*) 407 0x555555731f50 void WebCore::ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned int, unsigned int, const WebCore::Font*) 408 0x7fffe8fc7560 void WebCore::ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned int, unsigned int, const WebCore::Font*) 411 0x555555a9d0c0 void WebCore::ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned int, unsigned int, const WebCore::Font*) 412 0x555555731f50 void WebCore::ComplexTextController::collectComplexTextRunsForCharacters(const UChar*, unsigned int, unsigned int, const WebCore::Font*) 413 0x7fffe8fc7560

I have no knowledge of libharfbuzz and don't understand why it happens, maybe here are some alive people that might guide
me in correct direction, so i could fix the issue.

Lets soleve it and I will contribute back to the project with all that was already done + what's left to do.

@quarcko
Copy link
Author

quarcko commented Jan 15, 2024

Could it be that Qt 6.5.3 is linked against libicu 56
and while building webkit it linked agains system libicu 70 ?

and now when running

ldd libQt6WebKit.so.6.212.0 | grep libicu

i get this:

libicui18n.so.70 => /lib/x86_64-linux-gnu/libicui18n.so.70 (0x00007f44d3c00000)
libicuuc.so.70 => /lib/x86_64-linux-gnu/libicuuc.so.70 (0x00007f44d3a05000)
libicui18n.so.56 => /program_files/Qt-6.5.3/6.5.3/gcc_64/lib/libicui18n.so.56 (0x00007f44d2600000)
libicuuc.so.56 => /program_files/Qt-6.5.3/6.5.3/gcc_64/lib/libicuuc.so.56 (0x00007f44d2200000)
libicudata.so.56 => /program_files/Qt-6.5.3/6.5.3/gcc_64/lib/libicudata.so.56 (0x00007f44d0800000)
libicudata.so.70 => /lib/x86_64-linux-gnu/libicudata.so.70 (0x00007f44cea00000)

@quarcko
Copy link
Author

quarcko commented Jan 16, 2024

So it happens libICU has probably nothing to do with it. The issue is probably with libharfbuzz:
Because QT under the hood uses libharfbuzz-ng 8.3.0 and system one is 2.xx something.
And most probably when face is extracted from QFontEngine is incompatible struct or something. So here is what helps:

//Extract a blob from hb_face_t which is returned from QT's version of harfbuzz
NakedPtr<hb_blob_t> blob = hb_face_reference_blob (hb_qt_face_get_for_engine(fe));
//Use that blob to re-created face and font.
NakedPtr<hb_face_t> face(hb_face_create(blob.get(), 0));
NakedPtr<hb_font_t> harfBuzzFont(hb_font_create(face.get()));

and no more crashing. but: webpages look terribly:
webkit

As far as i tested: if webpage explicitly sets ifs own font - then it is displayed great
But if webpage is relaying on some system font - then you see result in screenshot.

What can be done further?

@quarcko
Copy link
Author

quarcko commented Jan 17, 2024

Ok, so after adding this code after creating Face and Font:

const float size = fontPlatformData.size();
if (floorf(size) == size)
hb_font_set_ppem(harfBuzzFont.get(), size, size);
int scale = floatToHarfBuzzPosition(size);
hb_font_set_scale(harfBuzzFont.get(), scale, scale);

rendering is fixed and QtTestBrowser displays web pages correctly.

@quarcko
Copy link
Author

quarcko commented Jan 18, 2024

created #24

@quarcko quarcko closed this as completed Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant