flypig.co.uk

List items

Items from the current list are shown below.

Gecko

30 Aug 2023 : Day 14 #
Let's quickly recap on what happened yesterday. We looked at the Rust components and style component in particular. It was generating a segfault which we eventually tracked down to the debug symbols.

Building without symbols seemed to fix the problem in the isolated context of building the single component, so after making the relevant changes to the build process, I'd set a complete rebuild to run overnight.

This morning all the indications are that style went through okay. The only error now showing up in the output is the font error we saw back on Day 10. Here's what it shows:
164:53.88 ${PROJECT}/gecko-dev/gfx/thebes/gfxFcPlatformFontList.cpp: In lambda function:
164:53.88 ${PROJECT}/gecko-dev/gfx/thebes/gfxFcPlatformFontList.cpp:1725:72: error: 
          could not convert ‘false’ from ‘bool’ to ‘mozilla::WeightRange’
164:53.88                                               weight,     stretch, style};
164:53.89                                                                         ^
164:53.89 ${PROJECT}/gecko-dev/gfx/thebes/gfxFcPlatformFontList.cpp:1725:72: error: 
          could not convert ‘weight’ from ‘gfxPlatformFontList::WeightRange’
          {aka ‘mozilla::WeightRange’} to ‘mozilla::StretchRange’
164:53.89 ${PROJECT}/gecko-dev/gfx/thebes/gfxFcPlatformFontList.cpp:1725:72: error:
          could not convert ‘stretch’ from ‘gfxPlatformFontList::StretchRange’
          {aka ‘mozilla::StretchRange’} to ‘mozilla::SlantStyleRange’
164:53.89 ${PROJECT}/gecko-dev/gfx/thebes/gfxFcPlatformFontList.cpp:1725:72: error:
          could not convert ‘style’ from ‘gfxPlatformFontList::SlantStyleRange’
          {aka ‘mozilla::SlantStyleRange’} to ‘RefPtr’
164:55.60 make[4]: *** [${PROJECT}/gecko-dev/config/rules.mk:676: gfxFcPlatformFontList.o] Error 1
This is the kind of issue I like: a nice, clear error in the code, rather than an obscure compiler bug or failure hidden deep in the build pipeline. The output tells us exactly where the issue is, and the job is to go through the code and match up the function prototype with the calling code.

So, here is the calling code taken from line 1725 of gfxFcPlatformFontList.cpp:
    auto initData = fontlist::Face::InitData{descriptor, 0,       size, false,
                                             weight,     stretch, style};
And looking carefully, it turns out it's not a call at all, but rather a struct initialiser (it has curly braces rather than parentheses). The principle is the same though: the input parameters need to match up with what the structure is expecting.

Looking a few lines up in the code we can see that the weight, stretch and style variables do have the types it's complaining about.
    WeightRange weight(FontWeight::Normal());
    StretchRange stretch(FontStretch::Normal());
    SlantStyleRange style(FontSlantStyle::Normal());
Comparing these to the error it looks like the constructor parameters have been shifted along by one, so either the false has been added to the constructor but not the structure, or something else has been added before it.

A quick search shows the fontlist::Face::InitData structure is defined in the SharedFontList.h file, in which we find it defined like this:
struct Face {
  // Data required to initialize a Face
  struct InitData {
    nsCString mDescriptor;  // descriptor that can be used to instantiate a
                            // platform font reference
    uint16_t mIndex;        // an index used with descriptor (on some platforms)
#ifdef MOZ_WIDGET_GTK
    uint16_t mSize;  // pixel size if bitmap; zero indicates scalable
#endif
    bool mFixedPitch;                  // is the face fixed-pitch (monospaced)?
    mozilla::WeightRange mWeight;      // CSS font-weight value
    mozilla::StretchRange mStretch;    // CSS font-stretch value
    mozilla::SlantStyleRange mStyle;   // CSS font-style value
    RefPtr mCharMap;  // character map, or null if not loaded
  };
From this the problem is immediately clear: the mSize parameter is being masked out by the MOZ_WIDGET_GTK pre-processor directive. For our build this is unset, but we still want to include the line that's being masked out.

It's a little baffling that there's no similar pre-processor condition in gfxFcPlatformFontList.cpp. It looks like the code is guaranteed to fail if MOZ_WIDGET_GTK hasn't been defined. But there it is. Probably there's something higher up the process that's preventing that bit of code from being built.

For our part, we can fix this by extending the pre-processor condition to include MOZ_WIDGET_QT which is our special "Sailfish OS" define, like this:
#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_QT)
    uint16_t mSize;  // pixel size if bitmap; zero indicates scalable
#endif
There are a few other places in the same file — and also in SharedFontList.cpp — that make use of the size variable. These also need amending, but all the changes are along similar lines.

Setting the build off after making these changes, it seems to be progressing a lot further than previously. That's a good sign.

After 88 minutes 2.08 seconds (according to the log output) it's still working away without having hit an error. That's definitely the furthest yet. But it's also pushed me way past my bed time. So I'll leave it running overnight and see where it's got to in the morning.

For all the other posts, check out my full Gecko Dev Diary.

Comments

Uncover Disqus comments