flypig.co.uk

List items

Items from the current list are shown below.

Blog

25 Jun 2024 : Day 269 #
This morning I awake to a failed build. It got right through to the end, so all the compilation went through successfully, but the linking step failed. That means I won't be able to test my changes from yesterday just yet. Here's the output. Linking errors are notoriously obtuse, but I've added linebreaks in to separate out the individual errors in an attempt to make things a little clearer:
226:05.55 toolkit/library/build/libxul.so

229:37.11 opt/cross/bin/aarch64-meego-linux-gnu-ld: ../../../gfx/layers/
    Unified_cpp_gfx_layers6.o: in function `mozilla::layers::
    SharedSurfaceTextureClient::Create(mozilla::UniquePtr<mozilla::gl::
    SharedSurface, mozilla::DefaultDelete<mozilla::gl::SharedSurface> >, 
    mozilla::gl::SurfaceFactory*, mozilla::layers::LayersIPCChannel*, mozilla::
    layers::TextureFlags)':
229:37.11 ${PROJECT}/gecko-dev/gfx/layers/client/TextureClientSharedSurface.cpp:
    104: undefined reference to `mozilla::layers::SharedSurfaceTextureData::
    SharedSurfaceTextureData(mozilla::UniquePtr<mozilla::gl::SharedSurface, 
    mozilla::DefaultDelete<mozilla::gl::SharedSurface> >)'

229:37.12 opt/cross/bin/aarch64-meego-linux-gnu-ld: ../../../gfx/layers/
    Unified_cpp_gfx_layers6.o: in function `already_AddRefed<mozilla::layers::
    SharedSurfaceTextureClient> mozilla::MakeAndAddRef<mozilla::layers::
    SharedSurfaceTextureClient, mozilla::layers::SharedSurfaceTextureData*&, 
    mozilla::layers::TextureFlags&, mozilla::layers::LayersIPCChannel*&>(
    mozilla::layers::SharedSurfaceTextureData*&, mozilla::layers::
    TextureFlags&, mozilla::layers::LayersIPCChannel*&)':
229:37.12 ${PROJECT}/obj-build-mer-qt-xr/dist/include/mozilla/RefPtr.h:590: 
    undefined reference to `mozilla::layers::SharedSurfaceTextureClient::
    SharedSurfaceTextureClient(mozilla::layers::SharedSurfaceTextureData*, 
    mozilla::layers::TextureFlags, mozilla::layers::LayersIPCChannel*)'

229:37.12 opt/cross/bin/aarch64-meego-linux-gnu-ld: libxul.so: hidden symbol 
    `_ZN7mozilla6layers24SharedSurfaceTextureDataC1ENS_9UniquePtrINS_2gl13
    SharedSurfaceENS_13DefaultDeleteIS4_EEEE' isn't defined

229:37.12 opt/cross/bin/aarch64-meego-linux-gnu-ld: final link failed: bad value
229:37.12 collect2: error: ld returned 1 exit status
That's a bit dense, but alongside the header and footer, we can see that this breaks down into three failures. First there's an undefined reference to a SharedSurfaceTextureData() constructor. The missing method has the following signature:
SharedSurfaceTextureData::SharedSurfaceTextureData(
    UniquePtr<SharedSurface,DefaultDelete<SharedSurface> >
)
The output also tells us that the reference to it happens in SharedSurfaceTextureClient::Create() on line 104 of TextureClientSharedSurface.cpp.

This is usually a sign that something was declared in the header but without an implementation in the source. And sure enough, checking the diff from the previous version I can see that there's this method that used to be in TextureClientSharedSurface.cpp but has been removed:
-SharedSurfaceTextureData::SharedSurfaceTextureData(
-    UniquePtr<gl::SharedSurface> surf)
-    : mSurf(std::move(surf)),
-      mDesc(),
-      mFormat(),
-      mSize(mSurf->mDesc.size)
-{
-}
Adding it back in was nice and easy and should fix this error. Next up there's another undefined reference. This one relates to this method:
SharedSurfaceTextureClient::SharedSurfaceTextureClient(
    SharedSurfaceTextureData*,
    TextureFlags,
    LayersIPCChannel*
)
The error shows that an attempt is being made to use this inside a MakeAndAddRef() call, but that's not very helpful for us because that's just a wrapper obscuring the real location. Nevertheless, checking the diff shows that the following relevant code has been removed from TextureClientSharedSurface.cpp:
-SharedSurfaceTextureClient::SharedSurfaceTextureClient(
-    SharedSurfaceTextureData* aData, TextureFlags aFlags,
-    LayersIPCChannel* aAllocator)
-    : TextureClient(aData, aFlags, aAllocator) {
-  mWorkaroundAnnoyingSharedSurfaceLifetimeIssues = true;
-}
This matches the missing signature and I can see there's also a matching signature for this already in the header file. So everything is aligning for this one as well. I've added the missing method body into the code.

Finally we have this hidden symbol error, which suggests that the following hasn't been defined:
_ZN7mozilla6layers24SharedSurfaceTextureDataC1ENS_9UniquePtrINS_2gl13
    SharedSurfaceENS_13DefaultDeleteIS4_EEEE
That's a horribly mangled name, but happily binutils provides the neat c++filt utility which will demangle it for us:
$ c++filt '_ZN7mozilla6layers24SharedSurfaceTextureDataC1ENS_9UniquePtrINS_2gl13
    SharedSurfaceENS_13DefaultDeleteIS4_EEEE'
mozilla::layers::SharedSurfaceTextureData::SharedSurfaceTextureData(
mozilla::UniquePtr<mozilla::gl::SharedSurface,
mozilla::DefaultDelete<mozilla::gl::SharedSurface> >)
Simplifying this output a bit, we can reduce it down to a missing symbol for the following:
SharedSurfaceTextureData::SharedSurfaceTextureData(
    UniquePtr<SharedSurface,
    DefaultDelete<SharedSurface> >
)
It looks like this is a repeat of our first error, so adding in the body for the missing SharedSurfaceTextureData should have already done the job of fixing this error.

With all of the errors apparently resolved, I've kicked the build off again.

[...]

The build quickly hits another error, but this error is happening during compilation as a result of the new code I added:
104:32.38 ${PROJECT}/gecko-dev/gfx/layers/client/TextureClientSharedSurface.cpp:
    109:3: error: ‘mWorkaroundAnnoyingSharedSurfaceLifetimeIssues’ was not 
    declared in this scope
104:32.38    mWorkaroundAnnoyingSharedSurfaceLifetimeIssues = true;
104:32.38    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This does appear in the new code we just added, but right now that's the only place it appears. It also appears in a bunch of code I've not added back in, all related to carefully choosing when to destroy shared surfaces. Since I'm not planning to add these back in just yet, I've commented out the offending line for now instead of adding the missing variable in. If any of the other pieces of infrastructure that need it get added in later, I can restore it. I've kicked off another build.

[...]

Now the compilation is going through successfully, but the build hit another few errors during linking:
222:47.06 toolkit/library/build/libxul.so

226:31.24 opt/cross/bin/aarch64-meego-linux-gnu-ld: ../../../gfx/layers/
    Unified_cpp_gfx_layers6.o: in function `mozilla::layers::
    SharedSurfaceTextureClient::SharedSurfaceTextureClient(mozilla::layers::
    SharedSurfaceTextureData*, mozilla::layers::TextureFlags, mozilla::layers::
    LayersIPCChannel*)':
226:31.24 ${PROJECT}/gecko-dev/gfx/layers/client/TextureClientSharedSurface.cpp:
    108: undefined reference to `vtable for mozilla::layers::
    SharedSurfaceTextureClient'

226:31.24 opt/cross/bin/aarch64-meego-linux-gnu-ld: ${PROJECT}/gecko-dev/gfx/
    layers/client/TextureClientSharedSurface.cpp:108: undefined reference to 
    `vtable for mozilla::layers::SharedSurfaceTextureClient'

226:31.25 opt/cross/bin/aarch64-meego-linux-gnu-ld: libxul.so: hidden symbol 
    `_ZTVN7mozilla6layers26SharedSurfaceTextureClientE' isn't defined

226:31.25 opt/cross/bin/aarch64-meego-linux-gnu-ld: final link failed: bad value
Let's break these down once again. From TextureClientSharedSurface.cpp line 108 we have an undefined reference to the SharedSurfaceTextureClient class's vtable. It looks to me like that's because the destructor is defined but not implemented.
-SharedSurfaceTextureClient::~SharedSurfaceTextureClient() {
-  // XXX - Things break when using the proper destruction handshake with
-  // SharedSurfaceTextureData because the TextureData outlives its gl
-  // context. Having a strong reference to the gl context creates a cycle.
-  // This needs to be fixed in a better way, though, because deleting
-  // the TextureData here can race with the compositor and cause flashing.
-  TextureData* data = mData;
-  mData = nullptr;
-
-  Destroy();
-
-  if (data) {
-    // Destroy mData right away without doing the proper deallocation 
    handshake,
-    // because SharedSurface depends on things that may not outlive the
-    // texture's destructor so we can't wait until we know the compositor isn't
-    // using the texture anymore. It goes without saying that this is really 
    bad
-    // and we should fix the bugs that block doing the right thing such as bug
-    // 1224199 sooner rather than later.
-    delete data;
-  }
-}
The second error looks to be the same thing. The third is mangled, so let's demangle it:
$ c++filt '_ZTVN7mozilla6layers26SharedSurfaceTextureClientE'
vtable for mozilla::layers::SharedSurfaceTextureClient
So apparently the third error is the same thing as well. I've added in the destructor, so let's give it another go.

[...]

Finally the build goes through. There's bad news and good news and good news and bad news.

The bad news is that after installing the packages the browser crashes with the same Wayland errors we were getting before.

The good news is that when I install the previous packages, then link in the new library to replace the previous version, the browser then works okay.

The subsequent good news is that the WebGL is also working when I do this.

And the final piece of news — bad news as it happens — is that the WebView doesn't work in this case.

Overall though, I take this to be positive. The build is working with the GLScreenBuffer restored (even if it's not being used). I now just need to figure out how to prevent the crash. After that I can focus on the WebView.

So it's gradually coming together.

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