Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit fcd6816

Browse files
egdanielSkia Commit-Bot
authored andcommitted
Fix crash on windows viewer when starting in vulkan.
setRequestedDisplayParams is called when setting up viewer before we've inited the Window. On windows this tries to attach the Window for a given backend. However, we haven't set fBackend yet. Later on we will directly call attach. Change-Id: I4bd6586478f2b040e5913314c4e47e92fc893a60 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/344756 Reviewed-by: Brian Osman <[email protected]> Commit-Queue: Greg Daniel <[email protected]>
1 parent 15f5184 commit fcd6816

File tree

7 files changed

+15
-2
lines changed

7 files changed

+15
-2
lines changed

tools/sk_app/Window.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class Window {
5252
virtual bool scaleContentToFit() const { return false; }
5353

5454
enum BackendType {
55+
kUnknown_BackendType,
5556
#ifdef SK_GL
5657
kNativeGL_BackendType,
5758
#endif

tools/sk_app/android/Window_android.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ void Window_android::initDisplay(ANativeWindow* window) {
6666
window_context_factory::MakeVulkanForAndroid(window, fRequestedDisplayParams);
6767
break;
6868
#endif
69+
case kUnknown_BackendType:
70+
SkUNREACHABLE;
6971
}
7072
this->onBackendCreated();
7173
}

tools/sk_app/ios/Window_ios.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ - (WindowViewController*)initWithWindow:(sk_app::Window_ios*)initWindow;
100100
case kRaster_BackendType:
101101
fWindowContext = MakeRasterForIOS(info, fRequestedDisplayParams);
102102
break;
103+
case kUnknown_BackendType:
104+
SkUNREACHABLE;
103105
}
104106
this->onBackendCreated();
105107

tools/sk_app/mac/Window_mac.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ - (MainView*)initWithWindow:(sk_app::Window_mac*)initWindow;
148148
case kRaster_BackendType:
149149
fWindowContext = MakeRasterForMac(info, fRequestedDisplayParams);
150150
break;
151+
case kUnknown_BackendType:
152+
SkUNREACHABLE;
151153
}
152154
this->onBackendCreated();
153155

tools/sk_app/unix/Window_unix.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,8 @@ bool Window_unix::attach(BackendType attachType) {
418418
fWindowContext =
419419
window_context_factory::MakeRasterForXlib(winInfo, fRequestedDisplayParams);
420420
break;
421+
case kUnknown_BackendType:
422+
SkUNREACHABLE;
421423
}
422424
this->onBackendCreated();
423425

tools/sk_app/win/Window_win.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ bool Window_win::attach(BackendType attachType) {
383383
window_context_factory::MakeD3D12ForWin(fHWnd, fRequestedDisplayParams);
384384
break;
385385
#endif
386+
case kUnknown_BackendType:
387+
SkUNREACHABLE;
386388
}
387389
this->onBackendCreated();
388390

@@ -403,7 +405,9 @@ void Window_win::setRequestedDisplayParams(const DisplayParams& params, bool all
403405
fWindowContext = nullptr;
404406
this->closeWindow();
405407
this->init(fHInstance);
406-
this->attach(fBackend);
408+
if (fBackend != kUnknown_BackendType) {
409+
this->attach(fBackend);
410+
}
407411
}
408412

409413
INHERITED::setRequestedDisplayParams(params, allowReattach);

tools/sk_app/win/Window_win.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Window_win : public Window {
3535

3636
HINSTANCE fHInstance;
3737
HWND fHWnd;
38-
BackendType fBackend;
38+
BackendType fBackend = kUnknown_BackendType;
3939

4040
using INHERITED = Window;
4141
};

0 commit comments

Comments
 (0)