Skip to content

Fix initial transparency of Web content layer #1811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

felipeerias
Copy link
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
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
Copy link
Collaborator Author

felipeerias commented Apr 16, 2025

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
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.

1 participant