Skip to content

Instantly share code, notes, and snippets.

@loic-sharma
Last active September 19, 2022 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loic-sharma/193abdacfbb369a7c5bb3c61757fa3df to your computer and use it in GitHub Desktop.
Save loic-sharma/193abdacfbb369a7c5bb3c61757fa3df to your computer and use it in GitHub Desktop.
ANGLE closes COM incorrectly
diff --git a/samples/gles1/HelloTriangle.cpp b/samples/gles1/HelloTriangle.cpp
index 0220b9678..2896ec547 100644
--- a/samples/gles1/HelloTriangle.cpp
+++ b/samples/gles1/HelloTriangle.cpp
@@ -13,6 +13,8 @@
// URLs: http://safari.informit.com/9780321563835
// http://www.opengles-book.com
+#include <objbase.h>
+
#include "SampleApplication.h"
#include "util/shader_utils.h"
@@ -50,6 +52,8 @@ class GLES1HelloTriangleSample : public SampleApplication
int main(int argc, char **argv)
{
+ ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
+
GLES1HelloTriangleSample app(argc, argv);
return app.run();
}
diff --git a/samples/sample_util/SampleApplication.cpp b/samples/sample_util/SampleApplication.cpp
index b583366e3..cacc207e0 100644
--- a/samples/sample_util/SampleApplication.cpp
+++ b/samples/sample_util/SampleApplication.cpp
@@ -14,7 +14,10 @@
#include "util/test_utils.h"
#include "util/util_gl.h"
+#include <objbase.h>
#include <string.h>
+#include <uiautomation.h>
+#include <wrl/implements.h>
#include <iostream>
#include <utility>
@@ -244,7 +247,9 @@ int SampleApplication::run()
return -1;
}
- mOSWindow->setVisible(true);
+ // Making the window visible does another COM initialization.
+ // This hides the fact that ANGLE is incorrectly closing COM.
+ // mOSWindow->setVisible(true);
ConfigParameters configParams;
configParams.redBits = 8;
@@ -260,6 +265,19 @@ int SampleApplication::run()
return -1;
}
+ // Creating this COM instance fails if line 253 is commented.
+ // This is because ANGLE's RoHelper has incorrectly closed COM.
+ Microsoft::WRL::ComPtr<IUIAutomationRegistrar> registrar;
+ if (FAILED(CoCreateInstance(CLSID_CUIAutomationRegistrar, nullptr, CLSCTX_INPROC_SERVER,
+ IID_IUIAutomationRegistrar, &registrar)))
+ {
+ std::cout << "BUG: Creating the COM instance failed!" << std::endl;
+ }
+ else
+ {
+ std::cout << "Success!" << std::endl;
+ }
+
// Disable vsync
if (!mGLWindow->setSwapInterval(0))
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment