Skip to content
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

api.CanvasRenderingContext2D.globalAlpha - Doesn't work after safari 16.x and also 17.x version #22633

Open
KKHKO opened this issue Mar 15, 2024 · 1 comment
Labels
data:api 🐇 Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API

Comments

@KKHKO
Copy link

KKHKO commented Mar 15, 2024

What type of issue is this?

Browser bug (a bug with a feature that may impact site compatibility)

What information was incorrect, unhelpful, or incomplete?

<style> #canvas { border: 1px solid black; } </style>
<script>
    
    const canvas = document.getElementById("canvas");
    const ctx = canvas.getContext("2d");

    
    ctx.fillStyle = "red";
    ctx.fillRect(50, 50, 200, 200);

    
    ctx.globalCompositeOperation = "destination-in";
	ctx.fillRect(50, 50, 200, 200);
    ctx.globalAlpha = 0.5;
    // 绘制目标形状(圆形)
    ctx.fillStyle = "blue";
    ctx.beginPath();
    ctx.arc(200, 200, 100, 0, Math.PI * 2);
    ctx.closePath();
    ctx.fill();
</script>

What browsers does this problem apply to, if applicable?

Safari

What did you expect to see?

The transparency of image doesn't work on safari

Did you test this? If so, how?

Yes, deployed my code and show it on safari

Can you link to any release notes, bugs, pull requests, or MDN pages related to this?

No response

Do you have anything more you want to share?

I am not sure exact safari version.

MDN URL

https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/globalAlpha

MDN metadata

MDN page report details
  • Query: api.CanvasRenderingContext2D.globalAlpha
  • Report started: 2024-03-15T03:49:59.009Z
@queengooborg
Copy link
Collaborator

The example on MDN works on both Chrome and Safari exactly the same, but I can confirm your code renders differently on both browsers.

Screenshot 2024-03-15 at 16 22 49 (Top: Chrome, bottom: Safari)

Once I take away the ctx.globalCompositeOperation = "destination-in"; line, however, both browsers render identically.

Screenshot 2024-03-15 at 16 24 07

I don't know how we would track this in BCD, but this isn't an issue that globalAlpha isn't supported. In the meantime, I'd recommend reporting the bug to WebKit.

@queengooborg queengooborg added the data:api 🐇 Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:api 🐇 Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API
Projects
None yet
Development

No branches or pull requests

2 participants