Closed wspl closed 2 years ago
Thanks! I don't have enough windows knowledge to know offhand that this is correct, can you point me to some documentation or something that explains what this is doing?
This doesn't seem right to me. If there are problems that surface when debug warnings are enabled, those may be real problems, and if so it's not a good idea to sweep them under the rug. In that case, it would be much better to figure out why the warnings are being produced and solve those.
One thing that I would be open to is setting warnings only in debug mode, especially if there is a measurable performance impact. But that's not a substitute for resolving what's causing the warnings.
I've read the linked issue. Hmm, it looks like maybe Direct2D is taking over the signal handling for Ctrl-C when this flag is set? That might be something to avoid.
@raphlinus It looks like this is a normal behavior of the debug mode of win32 apis/programs, and probably unavoidable (or does it require an exit signal sent via debug tools? I don't know much about this).
Enabling the debug mode of D2D1Factory via command line arguments or environment variable may be a better option. For this approach, see Node.js, which provides a --inspect
parameter to allow it communicate with the v8 debugger.
@cmyr The relevant documents I found: https://docs.microsoft.com/en-us/windows/win32/Direct2D/direct2ddebuglayer-overview
The Direct2D Debug Layer is really needed in some scenarios. So we need to find a way to turn it on conditionally, rather than by default.
Perhaps a suitable solution to this is using features, with something similar to how the log
crate can handle log levels.
[features]
release_level_error = []
release_level_warn = []
release_level_info = []
level_off = []
level_error = []
level_info = []
Perhaps defaulting to D2D1_DEBUG_LEVEL_NONE
for release builds and D2D1_DEBUG_LEVEL_WARNING
for debug builds. This means tests will run with warnings.
From the docs:
If no factory options are specified or a debug level of "none" is specified, the debug layer is not invoked. The debug layer should never be active in the release version of an application.
If an application (not library) author wanted to disable for debug builds due to the original issue then they could set with:
[target.'cfg(target_os="windows")'.dependencies]
piet-direct2d = { version = "=0.5.0", features = ["level_off"] }
Thanks @wspl for pushing this forward. There is now a solution to this via #517. I also discuss some potential future improvements with more granular control in that issue.
Closing this PR, as it has been superseded.
Related issues: https://github.com/linebender/druid/issues/2062 https://github.com/linebender/piet/issues/478
Initialize
D2D1Factory
withdebugLevel=D2D1_DEBUG_LEVEL_WARNING
will prevent programs from exiting with Ctrl+C under Windows.Disable the debug mode of D2D1Factory can solve this problem.