Closed Bug 1771493 Opened 2 years ago Closed 2 years ago

Refactor FontFace and FontFaceSet into facade and implementation classes

Categories

(Core :: Layout: Text and Fonts, task, P3)

task

Tracking

()

RESOLVED FIXED
104 Branch
Tracking Status
firefox104 --- fixed

People

(Reporter: aosmond, Assigned: aosmond)

References

(Regressed 1 open bug)

Details

Attachments

(4 files, 1 obsolete file)

With bug 1072107, we will want to make FontFace/FontFaceSet suitable to run on worker threads. Unfortunately these classes are closely intertwined with the Document, and various gfxFont* classes, which are primarily used on the main thread, even in the worker case. Hence we need to ensure we have a threadsafe refcounting implementation, which we cannot have for the DOM facing cycle collected objects. This bug aims to do a minimal split of FontFace into FontFace(Set) (DOM facing) and FontFace(Set)Impl (network/graphics facing) classes. Future bugs will iterate on this to enable worker implementations.

This patch aims to split the implementation details of FontFace(Set)
into FontFace(Set)Impl classes. The Impl variants have threadsafe
refcounting and are intended to be the basis for worker support for
FontFace(Set). We need threadsafe objects to pass around because parts
of the stack can only run on the main thread (network loading of font
data, graphics initialization of a font) even if the FontFace(Set)
itself lives on a DOM worker thread. Given the DOM facing objects are
cycle collected, we need additional indirection to support this use
case.

This patch should be a non-functional change.

Attachment #9278466 - Attachment description: WIP: Bug 1771493 - Split FontFace(Set) into DOM facing and implementation classes. → WIP: Bug 1771493 - Part 1. Split FontFace(Set) into DOM facing and implementation classes.

This patch merges FontFaceSetImpl and gfxUserFontSet into the same
class. This reduces the level of indirection and in theory makes it
easier to manage future threading issues.

Depends on D147505

This patch splits document specific functionality from FontFaceSetImpl
into a new class FontFaceSetDocumentImpl. This will make it easier to
fork FontFaceSetImpl for workers.

Depends on D147818

Attachment #9278466 - Attachment description: WIP: Bug 1771493 - Part 1. Split FontFace(Set) into DOM facing and implementation classes. → Bug 1771493 - Part 1. Split FontFace(Set) into DOM facing and implementation classes.
Attachment #9279022 - Attachment description: WIP: Bug 1771493 - Part 2. Merge FontFaceSetImpl and gfxUserFontSet into a single class. → Bug 1771493 - Part 2. Merge FontFaceSetImpl and gfxUserFontSet into a single class.
Attachment #9279023 - Attachment description: WIP: Bug 1771493 - Part 3. Abstract away buffer extraction from FontFaceImpl::InitializeSource. → Bug 1771493 - Part 3. Abstract away buffer extraction from FontFaceImpl::InitializeSource.
Attachment #9279024 - Attachment description: WIP: Bug 1771493 - Part 4. Split FontFaceSetDocumentImpl from FontFaceSetImpl. → Bug 1771493 - Part 4. Split FontFaceSetDocumentImpl from FontFaceSetImpl.
Pushed by aosmond@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/93b7e171c74a Part 1. Split FontFace(Set) into DOM facing and implementation classes. r=emilio https://hg.mozilla.org/integration/autoland/rev/fbfb5b7dfb30 Part 2. Merge FontFaceSetImpl and gfxUserFontSet into a single class. r=emilio https://hg.mozilla.org/integration/autoland/rev/5e6bf07c9c27 Part 3. Abstract away buffer extraction from FontFaceImpl::InitializeSource. r=emilio https://hg.mozilla.org/integration/autoland/rev/3f2605087550 Part 4. Split FontFaceSetDocumentImpl from FontFaceSetImpl. r=emilio

Backed out causing build bustages on FontFaceSet.cpp

Failure line: /builds/worker/checkouts/gecko/layout/style/FontFaceSet.cpp:250:8: error: variable 'removed' set but not used [-Werror,-Wunused-but-set-variable

Push with failures

Failure log

Backout link

[task 2022-06-28T14:49:31.729Z] 14:49:31     INFO -  1 warning generated.
[task 2022-06-28T14:49:31.729Z] 14:49:31     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/media/libcubeb/src'
[task 2022-06-28T14:49:31.733Z] 14:49:31     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/media/libcubeb/src'
[task 2022-06-28T14:49:31.733Z] 14:49:31     INFO -  media/libcubeb/src/cubeb_resampler.o
[task 2022-06-28T14:49:31.733Z] 14:49:31     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/media/libcubeb/src'
[task 2022-06-28T14:49:31.889Z] 14:49:31     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/media/libaom'
[task 2022-06-28T14:49:31.889Z] 14:49:31     INFO -  media/libaom/fft_avx2.o
[task 2022-06-28T14:49:31.892Z] 14:49:31     INFO -  /builds/worker/fetches/sccache/sccache /builds/worker/fetches/clang/bin/clang --sysroot /builds/worker/fetches/sysroot-x86_64-linux-gnu -std=gnu99 -o fft_avx2.o -c  -I/builds/worker/workspace/obj-build/dist/system_wrappers -include /builds/worker/checkouts/gecko/config/gcc_hidden.h -U_FORTIFY_SOURCE -fno-common -DNDEBUG=1 -DTRIMMED=1 -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DSTATIC_EXPORTABLE_JS_API -I/builds/worker/checkouts/gecko/media/libaom -I/builds/worker/workspace/obj-build/media/libaom -I/builds/worker/checkouts/gecko/media/libaom/config/linux/x64 -I/builds/worker/checkouts/gecko/media/libaom/config -I/builds/worker/checkouts/gecko/third_party/aom -I/builds/worker/workspace/obj-build/dist/include -I/builds/worker/workspace/obj-build/dist/include/nspr -I/builds/worker/workspace/obj-build/dist/include/nss -include /builds/worker/workspace/obj-build/mozilla-config.h -DMOZILLA_CLIENT -Qunused-arguments -fsanitize=bool,bounds,enum,function,integer-divide-by-zero,object-size,pointer-overflow,return,vla-bound -fno-sanitize-recover=bool,bounds,enum,function,integer-divide-by-zero,object-size,pointer-overflow,return,vla-bound -fsanitize-blacklist=/builds/worker/workspace/obj-build/ubsan_blacklist.txt -fsanitize=address -fcrash-diagnostics-dir=/builds/worker/artifacts -fPIC -ffunction-sections -fdata-sections -fno-math-errno -pthread -pipe -gdwarf-4 -Xclang -load -Xclang /builds/worker/workspace/obj-build/build/clang-plugin/libclang-plugin.so -Xclang -add-plugin -Xclang moz-check -O2 -gline-tables-only -fno-omit-frame-pointer -funwind-tables -Qunused-arguments -Wall -Wbitfield-enum-conversion -Wempty-body -Wformat-type-confusion -Wignored-qualifiers -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtype-limits -Wno-error=tautological-type-limit-compare -Wunreachable-code -Wunreachable-code-return -Wunused-but-set-parameter -Wclass-varargs -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wenum-compare-conditional -Werror=non-literal-null-conversion -Wstring-conversion -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=backend-plugin -Wno-error=free-nonheap-object -Wno-error=return-std-move -Wno-error=atomic-alignment -Wno-error=deprecated-copy -Wformat -Wformat-security -Wno-gnu-zero-variadic-macro-arguments -Werror=implicit-function-declaration -Wno-psabi -Wthread-safety -Wno-sign-compare -Wno-unused-function -Wno-unreachable-code -Wno-unneeded-internal-declaration -fno-strict-aliasing -ffp-contract=off  -MD -MP -MF .deps/fft_avx2.o.pp  -mavx2 /builds/worker/checkouts/gecko/third_party/aom/aom_dsp/x86/fft_avx2.c
[task 2022-06-28T14:49:31.892Z] 14:49:31     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/media/libaom'
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/layout/style'
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -  /builds/worker/fetches/sccache/sccache /builds/worker/fetches/clang/bin/clang++ --sysroot /builds/worker/fetches/sysroot-x86_64-linux-gnu -std=gnu++17 -o Unified_cpp_layout_style1.o -c  -I/builds/worker/workspace/obj-build/dist/stl_wrappers -I/builds/worker/workspace/obj-build/dist/system_wrappers -include /builds/worker/checkouts/gecko/config/gcc_hidden.h -U_FORTIFY_SOURCE -fno-common -DNDEBUG=1 -DTRIMMED=1 -DOS_POSIX=1 -DOS_LINUX=1 -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DSTATIC_EXPORTABLE_JS_API -I/builds/worker/checkouts/gecko/layout/style -I/builds/worker/workspace/obj-build/layout/style -I/builds/worker/workspace/obj-build/ipc/ipdl/_ipdlheaders -I/builds/worker/checkouts/gecko/ipc/chromium/src -I/builds/worker/checkouts/gecko/layout/base -I/builds/worker/checkouts/gecko/layout/generic -I/builds/worker/checkouts/gecko/layout/xul -I/builds/worker/checkouts/gecko/dom/base -I/builds/worker/checkouts/gecko/dom/html -I/builds/worker/checkouts/gecko/dom/xul -I/builds/worker/checkouts/gecko/image -I/builds/worker/workspace/obj-build/dist/include -I/builds/worker/workspace/obj-build/dist/include/nspr -I/builds/worker/workspace/obj-build/dist/include/nss -DMOZILLA_CLIENT -include /builds/worker/workspace/obj-build/mozilla-config.h -Qunused-arguments -Qunused-arguments -Wall -Wbitfield-enum-conversion -Wdeprecated-this-capture -Wempty-body -Wformat-type-confusion -Wignored-qualifiers -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtype-limits -Wno-error=tautological-type-limit-compare -Wunreachable-code -Wunreachable-code-return -Wunused-but-set-parameter -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wc++2a-compat -Wcomma -Wenum-compare-conditional -Wimplicit-fallthrough -Werror=non-literal-null-conversion -Wstring-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=backend-plugin -Wno-error=free-nonheap-object -Wno-error=return-std-move -Wno-error=atomic-alignment -Wno-error=deprecated-copy -Wformat -Wformat-security -Wno-gnu-zero-variadic-macro-arguments -Wno-psabi -Wthread-safety -Wno-unknown-warning-option -D_GLIBCXX_USE_CXX11_ABI=0 -fno-sized-deallocation -fno-aligned-new -fsanitize=bool,bounds,enum,function,integer-divide-by-zero,object-size,pointer-overflow,return,vla-bound -fno-sanitize-recover=bool,bounds,enum,function,integer-divide-by-zero,object-size,pointer-overflow,return,vla-bound -fsanitize-blacklist=/builds/worker/workspace/obj-build/ubsan_blacklist.txt -fsanitize=address -fcrash-diagnostics-dir=/builds/worker/artifacts -fno-exceptions -fPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -gdwarf-4 -Xclang -load -Xclang /builds/worker/workspace/obj-build/build/clang-plugin/libclang-plugin.so -Xclang -add-plugin -Xclang moz-check -O2 -gline-tables-only -fno-omit-frame-pointer -funwind-tables -Werror -fno-strict-aliasing -ffp-contract=off  -MD -MP -MF .deps/Unified_cpp_layout_style1.o.pp   Unified_cpp_layout_style1.cpp
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -  In file included from Unified_cpp_layout_style1.cpp:110:
[task 2022-06-28T14:49:31.954Z] 14:49:31    ERROR -  /builds/worker/checkouts/gecko/layout/style/FontFaceSet.cpp:250:8: error: variable 'removed' set but not used [-Werror,-Wunused-but-set-variable]
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -    bool removed = false;
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -         ^
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -  In file included from Unified_cpp_layout_style1.cpp:2:
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -  In file included from /builds/worker/checkouts/gecko/layout/style/CSSRuleList.cpp:7:
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -  In file included from /builds/worker/workspace/obj-build/dist/include/mozilla/dom/CSSRuleList.h:10:
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -  In file included from /builds/worker/workspace/obj-build/dist/include/mozilla/StyleSheetInlines.h:10:
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -  In file included from /builds/worker/workspace/obj-build/dist/include/mozilla/dom/Document.h:49:
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -  In file included from /builds/worker/workspace/obj-build/dist/include/mozilla/dom/AnimationFrameProvider.h:10:
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -  In file included from /builds/worker/workspace/obj-build/dist/include/mozilla/dom/AnimationFrameProviderBinding.h:12:
[task 2022-06-28T14:49:31.954Z] 14:49:31  WARNING -  /builds/worker/workspace/obj-build/dist/include/mozilla/dom/ToJSValue.h:414:3: warning: The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -    JS::RootedObject recordObj(aCx, JS_NewPlainObject(aCx));
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -    ^~~~~~~~~~~~~~~~
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -    JS::Rooted<JSObject*>
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -  1 warning and 1 error generated.
[task 2022-06-28T14:49:31.954Z] 14:49:31    ERROR -  gmake[4]: *** [/builds/worker/checkouts/gecko/config/rules.mk:668: Unified_cpp_layout_style1.o] Error 1
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/layout/style'
[task 2022-06-28T14:49:31.954Z] 14:49:31    ERROR -  gmake[3]: *** [/builds/worker/checkouts/gecko/config/recurse.mk:72: layout/style/target-objects] Error 2
[task 2022-06-28T14:49:31.954Z] 14:49:31     INFO -  gmake[3]: *** Waiting for unfinished jobs....
[task 2022-06-28T14:49:31.955Z] 14:49:31     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/layout/svg'
[task 2022-06-28T14:49:31.955Z] 14:49:31     INFO -  layout/svg/Unified_cpp_layout_svg2.o
[task 2022-06-28T14:49:31.956Z] 14:49:31     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/layout/svg'
[task 2022-06-28T14:49:32.004Z] 14:49:32     INFO -  gmake[4]: Entering directory '/builds/worker/workspace/obj-build/media/libcubeb/src'
[task 2022-06-28T14:49:32.004Z] 14:49:32     INFO -  /builds/worker/fetches/sccache/sccache /builds/worker/fetches/clang/bin/clang++ --sysroot /builds/worker/fetches/sysroot-x86_64-linux-gnu -std=gnu++17 -o cubeb_resampler.o -c  -I/builds/worker/workspace/obj-build/dist/stl_wrappers -I/builds/worker/workspace/obj-build/dist/system_wrappers -include /builds/worker/checkouts/gecko/config/gcc_hidden.h -U_FORTIFY_SOURCE -fno-common -DNDEBUG=1 -DTRIMMED=1 -DCUBEB_GECKO_BUILD -DUSE_PULSE_RUST -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL -DSTATIC_EXPORTABLE_JS_API -I/builds/worker/checkouts/gecko/media/libcubeb/src -I/builds/worker/workspace/obj-build/media/libcubeb/src -I/builds/worker/workspace/obj-build/dist/include -I/builds/worker/workspace/obj-build/dist/include/nspr -I/builds/worker/workspace/obj-build/dist/include/nss -DMOZILLA_CLIENT -include /builds/worker/workspace/obj-build/mozilla-config.h -Qunused-arguments -Qunused-arguments -Wall -Wbitfield-enum-conversion -Wdeprecated-this-capture -Wempty-body -Wformat-type-confusion -Wignored-qualifiers -Wpointer-arith -Wshadow-field-in-constructor-modified -Wsign-compare -Wtype-limits -Wno-error=tautological-type-limit-compare -Wunreachable-code -Wunreachable-code-return -Wunused-but-set-parameter -Wno-invalid-offsetof -Wclass-varargs -Wempty-init-stmt -Wfloat-overflow-conversion -Wfloat-zero-conversion -Wloop-analysis -Wno-range-loop-analysis -Wc++2a-compat -Wcomma -Wenum-compare-conditional -Wimplicit-fallthrough -Werror=non-literal-null-conversion -Wstring-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=backend-plugin -Wno-error=free-nonheap-object -Wno-error=return-std-move -Wno-error=atomic-alignment -Wno-error=deprecated-copy -Wformat -Wformat-security -Wno-gnu-zero-variadic-macro-arguments -Wno-psabi -Wthread-safety -Wno-unknown-warning-option -D_GLIBCXX_USE_CXX11_ABI=0 -fno-sized-deallocation -fno-aligned-new -fsanitize=bool,bounds,enum,function,integer-divide-by-zero,object-size,pointer-overflow,return,vla-bound -fno-sanitize-recover=bool,bounds,enum,function,integer-divide-by-zero,object-size,pointer-overflow,return,vla-bound -fsanitize-blacklist=/builds/worker/workspace/obj-build/ubsan_blacklist.txt -fsanitize=address -fcrash-diagnostics-dir=/builds/worker/artifacts -fno-exceptions -fPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -gdwarf-4 -Xclang -load -Xclang /builds/worker/workspace/obj-build/build/clang-plugin/libclang-plugin.so -Xclang -add-plugin -Xclang moz-check -O2 -gline-tables-only -fno-omit-frame-pointer -funwind-tables -fno-strict-aliasing -ffp-contract=off  -MD -MP -MF .deps/cubeb_resampler.o.pp   /builds/worker/checkouts/gecko/media/libcubeb/src/cubeb_resampler.cpp
[task 2022-06-28T14:49:32.004Z] 14:49:32     INFO -  gmake[4]: Leaving directory '/builds/worker/workspace/obj-build/media/libcubeb/src'
Flags: needinfo?(aosmond)

Updated and got a clean try for various opt builds.

Flags: needinfo?(aosmond)
Pushed by aosmond@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/aa5527055ad1 Part 1. Split FontFace(Set) into DOM facing and implementation classes. r=emilio https://hg.mozilla.org/integration/autoland/rev/1f5b0b087930 Part 2. Merge FontFaceSetImpl and gfxUserFontSet into a single class. r=emilio https://hg.mozilla.org/integration/autoland/rev/609a5d93bf08 Part 3. Abstract away buffer extraction from FontFaceImpl::InitializeSource. r=emilio https://hg.mozilla.org/integration/autoland/rev/22f567c00af3 Part 4. Split FontFaceSetDocumentImpl from FontFaceSetImpl. r=emilio
Pushed by csabou@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/07513973391f Part 5. Fix missing headers for FontFaceSet. CLOSED TREE

Backed out 5 changesets (Bug 1771493) for causing bustages on FontFaceSetDocumentImpl.obj.
Backout link
Push with failures
Failure Log 1, 2

Flags: needinfo?(aosmond)
Attachment #9283242 - Attachment is obsolete: true

Missing headers masked by unified builds I think. Will reland once I have confirmed the fix.

Flags: needinfo?(aosmond)
Pushed by aosmond@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3d30a8d83d77 Part 1. Split FontFace(Set) into DOM facing and implementation classes. r=emilio https://hg.mozilla.org/integration/autoland/rev/5a39eb924188 Part 2. Merge FontFaceSetImpl and gfxUserFontSet into a single class. r=emilio https://hg.mozilla.org/integration/autoland/rev/f724c21b1f15 Part 3. Abstract away buffer extraction from FontFaceImpl::InitializeSource. r=emilio https://hg.mozilla.org/integration/autoland/rev/ae329eaf22f7 Part 4. Split FontFaceSetDocumentImpl from FontFaceSetImpl. r=emilio
Regressions: 1779096
Regressions: 1779098
Regressions: 1781293
Regressions: 1791622
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: