movableink / webkit

Unofficial mirror of the WebKit SVN repository
http://www.webkit.org/
59 stars 11 forks source link

Built with QT 6.5.3 - crashes in libharfbuzz #23

Closed quarcko closed 7 months ago

quarcko commented 7 months ago

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::operator* (this=) 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=) 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=, table_tag=,

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=)

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

created https://github.com/movableink/webkit/pull/24