2018 R4 loss of transparency in Canvas

Well something happened with R4 that breaks my whole UI. Not so happy about that. Bigger issues is I can’t figure out what the fix is.

The window below looks fine in R3, no black background on the canvas. In r4 some of my canvas images display a back background where as others are correctly transparent.

The icons in the middle section of the window all have the same settings but one has the black background artifact, the others do not.
The top portion of the window has canvas over a rectangle, the middle section has canvases over a page panel.
All the options in the inspector window under behavior heading are disabled.

Would like to file a bug report but right now i’m not sure how to reproduce. Specifically why it affects some canvases but not others. Just rolled back to R3 and everything works again, so that rules out the images being corrupted.

Hello, Julian

Try to put new canvas with the same images and see if it does not solve, I had a problem similar to some time ago and only to solve deleting the old canvas and putting new ones in the project

I’ll test later, that said if this is the issue there is a change to the way the project code is being compiled rather than the project just being corrupted. Also the size and scope of my project make this a major undertaking so not really a work around in this case.

I’m also seeing the issue when I draw directly into a canvas. I have a canvas class that creates a recessed group box and this also shows a strange artifact around the line and arc drawing methods.

Make sure that the Transparent property is True on the canvases that are black.

Forgot one detail that makes this more interesting. This is running on macOS. I’ve never had any issues with transparency on mac, Windows sure. We just went through and per the latest guidelines removed the transparency flag from many of our controls to improve drawing speed.

Is it not true that transparency should have no effect on mac?

Any insights on to what may have changed under the hood since the R3? We were really happy with the improvement introduced in R3 for windows, was not expecting to have to deal with issue on macOS now.

Okay so I can confirm that setting transparency does resolve the issue but here’s the questions:

  1. The behavior in R3, and supported by the docs, is that transparency on Mac should have no effect on a canvas - In R4 with my app it does. Is that the expected behavior?

To provide some more detail I created a new test project with the same assets placed over a new window and the project worked as expected with the PNG assets appearing with a transparent background. So there’s some combination of factors in my app that’s causing the problem. The oddest part is that controls with the same properties on the same page, only some will show the issues.

Also I’m currently running in dark mode on my mac but the windows have a custom color and supportdarkmode is set to false.

IT’s very difficult for me to upload my app so any other thoughts? still trying to find a way to replicate the issue in a sample project.

This isn’t a bug. What’s changed is that while it didn’t matter before, now it does. A new canvas dragged to a layout will have the Transparent property set to True on macOS. If you need different values per platform, you can set it in the open event with something like:

me.Transparent = TargetMacOS

Just so I’m interpreting that correctly:

The transparency property on macOS now has an effect.
The transparency property, which wast needed in the past to have transparency, is now needed…at least in some cases.

The only reference to transparency in the Release Notes for r4 is

“53628 Framework » Macintosh (Cocoa) Listbox now obeys the Transparent property on macOS.”

Seems the release notes are incomplete.

Okay I finally was able to make a sample project that shows the issue. All the canvases on the page have the transparency property set to off, but half of them are transparent like in previous version. The others are not. No idea why the difference, will link to feedback one I have it created

Having not played around with macos much, what woild be the use case for disabling canvas transparency on macos? Saving one call to fillrect with a black background?

<https://xojo.com/issue/54430>
Here’s the link to the case with a demo project. Curious if it’s system dependent?

Internally there are performance improvements, if you don’t need transparency, you can disable it and then the system doesn’t need to refresh any underlying controls, when refreshing it.

As far as Apple are concerned, unless you need transparency you should turn this off.

With the changes to the windows architecture we updated our app, disabling transparency as this was no longer needed in most cases and dramatically improved performance on windows. Now with this release I’d have to turn transparency on for all controls on a macOS build which has never been needed in the past. I haven’t tried this on windows but its introduced a feeling that the ui is a moving target and we can’t keep modifying controls on hundreds of windows to adapt to the latest best practices for the framework.

Okay this is a weird one!!

I can now reproduce the issue and it seems to be related to labels in Rectcontrols. Placing a label within a rectangle affects the transparency of a canvas control. Moving the label outside of the rectangle produces results identical to R3 projects.


Nothing was changed to the canvas and it contains no image. Transparency is set to “off”. Simply changing the parent of the label causes the canvas to be rendered with a black background. I’m guessing some of the optimization to the label control is responsible. I would call this a bug as the state of a canvas should not be impacted by controls that do not overlap with it.

Steps to reproduce are below:
Tested in macOS 10.14, darkmode on.

  1. Create a new desktop project
    Add a canvas to window, set transparency to false
    Add a rectangle to window, set the fill color to any color other than white (not sure this is required). Do not overlap.
    Add a label in the main window, not within the rectangle. Set text color to white ( not sure this is necessary)

//Test 1, same behavior as R3
Run the app and the canvas is not visible

//Test 2, different behavior from R3, Not expected behavior
Move the label into the rectangle
run the app
The canvas is rendered with a black fill

[quote=417908:@Julian Mussi]Steps to reproduce are below:
Tested in macOS 10.14, darkmode on.[/quote]
Good catch and weird! Make sure you file a feedback bug report and include your sample project.

Yeah there’s an attached case and sample project if anyone wants to test on a different version of macOS or sign onto the case. #54430

Could this be related to https://forum.xojo.com/50285-clearrect-uses-wrong-background-colour-in-dark-mode ?

I think LR should be updated about this, because it still states that Transparent works on Windows only,
While dragging a new canvas in a project, it has Transparent ON by default.