Calling ShowModal() on a wxColourDialog causes the application to continuously use 100% of one CPU core while the colour dialog is open.
Opening a wxColourDialog with ShowModal() should not cause excessive CPU usage while the dialog is idle. CPU usage should remain low when there is no user interaction.
After wxColourDialog::ShowModal() is called, the application continuously uses 100% of one CPU core, even when the colour dialog is idle and no user interaction is taking place.
The high CPU usage stops when the colour dialog is closed.
As a comparison, when using NSColorPanel directly through Objective-C/AppKit and calling runModalForWindow:, CPU usage is negligible while the colour panel is idle. This suggests that the high CPU usage is specific to the wxWidgets implementation rather than an inherent behaviour of the native macOS color panel.
#include <wx/button.h> #include <wx/colordlg.h> #include <wx/colourdata.h> #include <wx/sizer.h> #include <wx/wx.h> class MyApp : public wxApp { public: bool OnInit() override; }; wxIMPLEMENT_APP(MyApp); class MyFrame : public wxFrame { public: MyFrame(); private: void OnSelect(wxCommandEvent &event); }; bool MyApp::OnInit() { MyFrame *frame = new MyFrame(); frame->Show(true); return true; } MyFrame::MyFrame() : wxFrame(nullptr, wxID_ANY, "Hello World") { wxMenuBar *menuBar = new wxMenuBar; SetMenuBar(menuBar); auto sizer = new wxBoxSizer(wxVERTICAL); auto getColor = new wxButton(this, wxID_ANY, "select color"); getColor->Bind(wxEVT_BUTTON, &MyFrame::OnSelect, this); sizer->Add(getColor, 1, wxALIGN_CENTER); this->SetSizer(sizer); } void MyFrame::OnSelect(wxCommandEvent &event) { wxColourData data; data.SetColour(wxColour(0, 0, 255)); wxColourDialog dlg(this, &data); dlg.ShowModal(); }
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
Can you check what's going on under debugger? It probably keeps generating/processing some event or doing something during idle time but I don't know what it could be.
Also, I guess the problem is reproducible in the dialogs sample (which has a menu item to show this dialog) without any modifications.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()