Skip to content

Fix initial transparency of Web content layer#1811

Open
felipeerias wants to merge 1 commit into
mainfrom
felipeerias/transparentWebLayer
Open

Fix initial transparency of Web content layer#1811
felipeerias wants to merge 1 commit into
mainfrom
felipeerias/transparentWebLayer

Conversation

@felipeerias

Copy link
Copy Markdown
Collaborator

This PR is a first step towards fixing the problem that the window containing Web content appears transparent for a few seconds (issue #1766).

The problem seems to be related to the fact that we are enabling alpha blending for that layer even though it already has an opaque clear colour.

However, changing that XR flag is not enough to fully fix the issue: initially the layer appears completely black, followed by the expected clear color (but too bright).

@felipeerias felipeerias requested a review from svillar March 18, 2025 02:38
@felipeerias felipeerias force-pushed the felipeerias/transparentWebLayer branch from 0cdca2c to c0a4aad Compare April 15, 2025 11:40
@felipeerias

Copy link
Copy Markdown
Collaborator Author

The initialisation of the browser windows seems to conflict with some of the changes at #577

Specifically, the windows are not composited for a couple seconds after they have been created, which triggers this code:

    if (mCompositionLayerColorScaleBias != XR_NULL_HANDLE) {
        vrb::Color tintColor = layer->GetTintColor();
        if (!IsComposited() && (layer->GetClearColor().Alpha() > 0.0f)) {
            tintColor = layer->GetClearColor();
            tintColor.SetRGBA(tintColor.Red(), tintColor.Green(), tintColor.Blue(), tintColor.Alpha());
        }
        mCompositionLayerColorScaleBiasStruct.colorScale = {tintColor.Red(), tintColor.Green(), tintColor.Blue(), tintColor.Alpha()};
    }

Upon creation, the window layer has these attributes:

  • composited is false
  • clearColor is set to our desired color, for example rgba(0.14,0.14,0.15,1.00)
  • tint is set to white (rgba(1.00,1.00,1.00,1.00)) so the content is not modified

But with this code, colorScale becomes the same as the clearColor:

  • colorScale is rgba(0.14,0.14,0.15,1.00)

What this means is that the clear color is being multiplied by itself, which will make it look different than expected.

@felipeerias

felipeerias commented Apr 16, 2025

Copy link
Copy Markdown
Collaborator Author

Another useful change would be to allow us to set the background color for a website, similar to GeckoView.coverUntilFirstPaint.

Edit: implemented in PR #1827

@felipeerias felipeerias force-pushed the felipeerias/transparentWebLayer branch from c0a4aad to 4db7e12 Compare April 16, 2025 05:34
@felipeerias felipeerias force-pushed the felipeerias/transparentWebLayer branch 2 times, most recently from c9100db to 55728f7 Compare April 17, 2025 07:02
@felipeerias

Copy link
Copy Markdown
Collaborator Author

Partial fix for #1766

@felipeerias felipeerias added the release_candidate PR that should be part of the next release label May 16, 2025
@svillar svillar removed the release_candidate PR that should be part of the next release label Oct 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants