Skip to content

Conversation

@dpasukhi
Copy link
Member

Suppress Metal initialization errors on macOS by pre-warming graphics context

dpasukhi added 2 commits July 30, 2025 09:57
Suppress Metal initialization errors on macOS by pre-warming graphics context
@dpasukhi dpasukhi added this to the Release 8.0 milestone Jul 30, 2025
@dpasukhi dpasukhi requested a review from Copilot July 30, 2025 09:09
@dpasukhi dpasukhi self-assigned this Jul 30, 2025
@dpasukhi dpasukhi added 1. DRAW TCL scripts, OCCT DRAW commands and plug-ins 1. Testing Updating of the DRAW/GTests or GH tests labels Jul 30, 2025
@dpasukhi dpasukhi changed the base branch from master to IR July 30, 2025 09:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes image generation issues on macOS by implementing Metal initialization error suppression through graphics context pre-warming. The fix addresses crashes or errors that occur during Metal framework initialization on macOS systems.

  • Added Metal initialization pre-warming logic to suppress graphics context errors
  • Updated version from rc1 to rc2 to reflect the fix
  • Expanded test coverage to include additional test suites

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Draw/TKDraw/Draw/Draw_Window_1.mm Implements Metal initialization pre-warming with error suppression
adm/cmake/version.cmake Updates development version from rc1 to rc2
.github/actions/testgrid/testmacos.tcl Expands test coverage to include helix and standard test suites

Comment on lines 179 to 180
static bool isMetalInitialized = false;
if (!isMetalInitialized) {
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The static boolean variable isMetalInitialized is not thread-safe. If this function can be called from multiple threads, consider using std::once_flag with std::call_once or adding proper synchronization to prevent race conditions during Metal initialization.

Suggested change
static bool isMetalInitialized = false;
if (!isMetalInitialized) {
static std::once_flag metalInitFlag;
std::call_once(metalInitFlag, []() {

Copilot uses AI. Check for mistakes.
Comment on lines 188 to 189
@catch (NSException*) {
// Ignore any Metal initialization exceptions
Copy link

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catching all NSException types without specifying the exception type or logging the error could hide important debugging information. Consider logging the exception details or catching more specific exception types to aid in troubleshooting Metal initialization issues.

Suggested change
@catch (NSException*) {
// Ignore any Metal initialization exceptions
@catch (NSException* exception) {
// Log Metal initialization exceptions for debugging purposes
NSLog(@"Metal initialization failed with exception: %@ - %@", [exception name], [exception reason]);

Copilot uses AI. Check for mistakes.
@dpasukhi dpasukhi marked this pull request as draft July 30, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1. DRAW TCL scripts, OCCT DRAW commands and plug-ins 1. Testing Updating of the DRAW/GTests or GH tests

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant