flypig.co.uk

List items

Items from the current list are shown below.

Blog

24 Jun 2024 : Day 268 #
Today hasn't quite been the day of development I was planning. That's okay, it happens sometimes, and while I've not been doing development, the sun has been shining and nature has been making it's lazy hum. It's not been bad to take the opportunity to relax.

What's more, my day was made emphatically better by receiving this Gecko-dev related poem from Leif-Jöran Olsson (ljo) on Mastodon:

Summer solstice and a supporting full moon ends the code removal phase. A sea of browser backtrace ejects gives support for switching to incremental introduction of nibbles of code. The WebGL context path is buried together with any remaining anxiety. The energy collected awakens the concavenator to pair up in dynamic duo with flypig's rejuvenated gecko.

Genuine art! It sums up where things are at nicely, as you may recall I've recently restored GLScreenBuffer alongside a minimal set of changes (the convex hull of its dependencies) need to get the build to compile. Partial compile that is.

I kicked off a build overnight, but by the morning it's hit some errors. They look like this:
[...]
254:42.53 ${PROJECT}/gecko-dev/mobile/sailfishos/embedthread/
    EmbedLiteCompositorBridgeParent.cpp: In member function ‘void mozilla::
    embedlite::EmbedLiteCompositorBridgeParent::GetPlatformImage(const std::
    function<void(void*, int, int)>&)’:
254:42.53 ${PROJECT}/gecko-dev/mobile/sailfishos/embedthread/
    EmbedLiteCompositorBridgeParent.cpp:227:37: error: ‘class mozilla::gl::
    GLContext’ has no member named ‘Screen’
254:42.53    GLScreenBuffer* screen = context->Screen();
254:42.53                                      ^~~~~~

254:42.53 ${PROJECT}/gecko-dev/mobile/sailfishos/embedthread/
    EmbedLiteCompositorBridgeParent.cpp: In member function ‘void* mozilla::
    embedlite::EmbedLiteCompositorBridgeParent::GetPlatformImage(int*, int*)’:
254:42.53 ${PROJECT}/gecko-dev/mobile/sailfishos/embedthread/
    EmbedLiteCompositorBridgeParent.cpp:257:37: error: ‘class mozilla::gl::
    GLContext’ has no member named ‘Screen’
254:42.53    GLScreenBuffer* screen = context->Screen();
254:42.53                                      ^~~~~~

254:44.41 make[4]: *** [${PROJECT}/gecko-dev/config/rules.mk:694: 
    EmbedLiteCompositorBridgeParent.o] Error 1
In this and the following error output I've added some newlines to try to separate out the errors and hopefully make them a little clearer.

All of these errors amount to the same thing and will be easy to fix. The necessary change is to restore the GLContext::Screen() method, which I've done, and set the build off again. It presumably got past the partial build because the call is being made from inside EmbedLiteCompositorBridgeParent.cpp, which as I also discussed yesterday, doesn't get touched by the partial build.

It was a pretty obvious error and someone more astute than I am could certainly have picked it up just by observation, without the need to do the build. But it's also easy when working with compiled languages to rely on the compiler to pick these kinds of errors up. So I missed it and it lost me some time.

My second build failed as well, this time due to the following variable being missing from the GLContext class:
  UniquePtr<GLScreenBuffer> mScreen;
In my defence I had added it, but it got removed again while performing a git checkout -d command to restore the Screen() method. It's a poor defence, but it's how it went down.

So I'm now on to my third build of the day. So far so good, I'm hoping it'll complete before bed-time so as to give me the chance to test it.

Frustratingly it gets all the way to the linker before it fails again.
394:09.19 toolkit/library/build/libxul.so

401:01.08 /home/flypig/Programs/sailfish-sdk/sailfish-sdk/mersdk/targets/
    SailfishOS-devel-aarch64.default/opt/cross/bin/aarch64-meego-linux-gnu-ld: 
    ../../../gfx/gl/Unified_cpp_gfx_gl0.o: in function `mozilla::gl::
    SurfaceFactory::NewTexClient(mozilla::gfx::IntSizeTyped<mozilla::gfx::
    UnknownUnits> const&)':
401:01.10 ${PROJECT}/gecko-dev/gfx/gl/SharedSurface.cpp:204: undefined 
    reference to `mozilla::layers::SharedSurfaceTextureClient::Create(mozilla::
    UniquePtr<mozilla::gl::SharedSurface, mozilla::DefaultDelete<mozilla::gl::
    SharedSurface> >, mozilla::gl::SurfaceFactory*, mozilla::layers::
    LayersIPCChannel*, mozilla::layers::TextureFlags)'

401:01.10 /home/flypig/Programs/sailfish-sdk/sailfish-sdk/mersdk/targets/
    SailfishOS-devel-aarch64.default/opt/cross/bin/aarch64-meego-linux-gnu-ld: 
    libxul.so: hidden symbol 
    `_ZN7mozilla6layers26SharedSurfaceTextureClient6CreateENS_9UniquePtr
    INS_2gl13SharedSurfaceENS_13DefaultDeleteIS4_EEEEPNS3_14SurfaceFactory
    EPNS0_16LayersIPCChannelENS0_12TextureFlagsE' isn't defined

401:01.10 /home/flypig/Programs/sailfish-sdk/sailfish-sdk/mersdk/targets/
    SailfishOS-devel-aarch64.default/opt/cross/bin/aarch64-meego-linux-gnu-ld: 
    final link failed: bad value
The problem here is a method that's being declared in a header but not implemented in the source file. By carefully working through the error output we can see that the missing code is the implementation for SharedSurfaceTextureClient::Create(). Here's the method shown in the error message, but cleaned up and reformatted to make things clearer:
SharedSurfaceTextureClient::Create(
    UniquePtr<SharedSurface, DefaultDelete<SharedSurface> >,
    SurfaceFactory*,
    LayersIPCChannel*,
    TextureFlags
)
We can also see from the error messages that it's being called here:
  RefPtr<layers::SharedSurfaceTextureClient> ret;
  ret = layers::SharedSurfaceTextureClient::Create(std::move(surf), this,
                                                   mAllocator, mFlags);
In TextureClientSharedSurface.h we can see the method signature in the header. The fact there's a signature is the reason the compiler didn't notice and it wasn't until the linker that the error was uncovered:
class SharedSurfaceTextureClient : public TextureClient {
 public:
[...]
  static already_AddRefed<SharedSurfaceTextureClient> Create(
      UniquePtr<gl::SharedSurface> surf, gl::SurfaceFactory* factory,
      LayersIPCChannel* aAllocator, TextureFlags aFlags);
[...]
};
But the implementation is indeed missing from TextureClientSharedSurface.cpp. We can get the implementation that we were using before using git diff, which gives us the following:
$ git diff
[...]
-already_AddRefed<SharedSurfaceTextureClient> SharedSurfaceTextureClient::
    Create(
-    UniquePtr<gl::SharedSurface> surf, gl::SurfaceFactory* factory,
-    LayersIPCChannel* aAllocator, TextureFlags aFlags) {
-  if (!surf) {
-    return nullptr;
-  }
-  TextureFlags flags = aFlags | TextureFlags::RECYCLE | surf->GetTextureFlags(
    );
-  SharedSurfaceTextureData* data =
-      new SharedSurfaceTextureData(std::move(surf));
-  return MakeAndAddRef<SharedSurfaceTextureClient>(data, flags, aAllocator);
-}
There's also a mangled method name appearing in the error output. We can demangle it to try to find out if this is something separate we need to fix: $ c++filt '_ZN7mozilla6layers26SharedSurfaceTextureClient6CreateENS_9 UniquePtrINS_2gl13SharedSurfaceENS_13DefaultDeleteIS4_EEEEPNS3_14 SurfaceFactoryEPNS0_16LayersIPCChannelENS0_12TextureFlagsE' mozilla::layers::SharedSurfaceTextureClient::Create(mozilla::UniquePtr >, mozilla::gl::SurfaceFactory*, mozilla::layers::LayersIPCChannel*, mozilla::layers::TextureFlags) Cleaning that up, we get this:
SharedSurfaceTextureClient::Create(
    UniquePtr<SharedSurface, DefaultDelete<SharedSurface> >,
    SurfaceFactory*,
    LayersIPCChannel*,
    TextureFlags
)
Having demangled and cleaned it up, it's clear this is the same error as before, so nothing more to do on this front.

After making these fixes and running the partial build again, it now throws up the following error:
In file included from Unified_cpp_gfx_layers6.cpp:128:
${PROJECT}/gecko-dev/gfx/layers/client/TextureClientSharedSurface.cpp: In 
    static member function ‘static already_AddRefed<mozilla::layers::
    SharedSurfaceTextureClient> mozilla::layers::SharedSurfaceTextureClient::
    Create(mozilla::UniquePtr<mozilla::gl::SharedSurface>, mozilla::gl::
    SurfaceFactory*, mozilla::layers::LayersIPCChannel*, mozilla::layers::
    TextureFlags)’:
${PROJECT}/gecko-dev/gfx/layers/client/TextureClientSharedSurface.cpp:102:63: 
    error: ‘class mozilla::gl::SharedSurface’ has no member named 
    ‘GetTextureFlags’
   TextureFlags flags = aFlags | TextureFlags::RECYCLE | surf->GetTextureFlags(
    );
To fix this I need to add in the removed GetTextureFlags() method to SharedSurface.cpp and the related signature in the SharedSurface.h header:
-  // Specifies to the TextureClient any flags which
-  // are required by the SharedSurface backend.
-  virtual layers::TextureFlags GetTextureFlags() const;
[...]
-layers::TextureFlags SharedSurface::GetTextureFlags() const {
-  return layers::TextureFlags::NO_FLAGS;
-}
With this change the partial build finally goes through, including the final linking stage. But I'll still need to run the full build again before I can test anything. So I've kicked it off. There's no way it'll complete before the morning, so that'll have to be it for the day.

If you'd like to read any of my other gecko diary entries, they're all available on my Gecko-dev Diary page.

Comments

Uncover Disqus comments