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

Fixed multi-threading causing view read failure #16253

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions native/cocos/platform/mac/modules/Screen.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ of this software and associated engine source code (the "Software"), a limited,
#include "base/Macros.h"
#include "cocos/bindings/jswrapper/SeApi.h"
#include "platform/interfaces/modules/ISystemWindowManager.h"
#include "platform/interfaces/modules/ISystemWindow.h"
#include "platform/mac/modules/SystemWindow.h"
#include "application/ApplicationManager.h"
namespace cc {

Expand All @@ -52,8 +52,8 @@ of this software and associated engine source code (the "Software"), a limited,
global->getProperty("devicePixelRatio", &devicePixelRatioVal);
return devicePixelRatioVal.isNumber() ? devicePixelRatioVal.toFloat() : 1.F;
#else
auto* window = CC_GET_MAIN_SYSTEM_WINDOW();
NSWindow* nsWindow = reinterpret_cast<NSWindow*>(window->getWindowHandle()) ;
auto* systemWindow = static_cast<SystemWindow*>(CC_GET_MAIN_SYSTEM_WINDOW());
auto* nsWindow = systemWindow->getNSWindow();
return [nsWindow backingScaleFactor];
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion native/cocos/platform/mac/modules/SystemWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ of this software and associated documentation files (the "Software"), to deal
[view addSubview:newView];
[nsWindow.contentView setWantsBestResolutionOpenGLSurface:YES];
[nsWindow makeKeyAndOrderFront:nil];
_windowHandle = reinterpret_cast<uintptr_t>(nsWindow.contentView) ;
_windowHandle = reinterpret_cast<uintptr_t>(newView);

auto dpr = [nsWindow backingScaleFactor];
_width = w * dpr;
Expand Down
7 changes: 0 additions & 7 deletions native/cocos/renderer/gfx-metal/MTLSwapchain.mm
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ of this software and associated engine source code (the "Software"), a limited,
if (!layer.device) {
layer.device = MTLCreateSystemDefaultDevice();
}
#elif CC_PLATFORM == CC_PLATFORM_MACOS
CAMetalLayer *layer = nullptr;
auto *view = (CCView *)info.windowHandle;
if(view && view.subviews.count > 0) {
NSView* subView = view.subviews[0];
layer = static_cast<CAMetalLayer *>(subView.layer);
}
#else
auto *view = (CCView *)info.windowHandle;
CAMetalLayer *layer = static_cast<CAMetalLayer *>(view.layer);
Expand Down