High CPU usage on Windows when using a wxNotebook with long tab titles. (Issue #25797)

38 views
Skip to first unread message

Quin Gillespie

unread,
Sep 14, 2025, 10:29:53 PM (10 days ago) Sep 14
to wx-...@googlegroups.com, Subscribed
trypsynth created an issue (wxWidgets/wxWidgets#25797)

Description

Bug description:

When I run the provided code sample on Windows, I see the CPU usage of my app rising quite high, and my screen reader navigation lags. If I shorten the length of the title strings, the CPU usage goes way down.

Expected vs observed behaviour:

CPU usage should remain low, as we're doing nothing intensive.

Patch or snippet allowing to reproduce the problem:

\#include <memory>
#include <wx/bookctrl.h>
#include <wx/wx.h>

class app : public wxApp {
public:
	bool OnInit() override {
		frame = new wxFrame(nullptr, wxID_ANY, "Test");
		auto* panel = new wxPanel(frame);
		notebook = new wxNotebook(panel, wxID_ANY);
		auto* sizer = new wxBoxSizer(wxVERTICAL);
		sizer->Add(notebook, 1, wxEXPAND | wxALL, 10);
		panel->SetSizer(sizer);
		auto* panel1 = create_tab_panel("This is a test.");
		auto* panel2 = create_tab_panel("This is a test.");
		notebook->AddPage(panel1, "This is a test of a very long title This is a test of a very long title This is a test of a very long title");
		notebook->AddPage(panel2, "This is a test of a very long title This is a test of a very long title This is a test of a very long title");
		frame->Show(true);
		return true;
	}

	wxPanel* create_tab_panel(const wxString& content) {
		wxPanel* panel = new wxPanel(notebook, wxID_ANY);
		auto* sizer = new wxBoxSizer(wxVERTICAL);
		long style = wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH2 | wxTE_DONTWRAP;
		auto* text_ctrl = new wxTextCtrl(panel, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, style);
		sizer->Add(text_ctrl, 1, wxEXPAND | wxALL, 5);
		panel->SetSizer(sizer);
		text_ctrl->SetValue(content);
		return panel;
	}

private:
	wxFrame* frame{nullptr};
	wxNotebook* notebook{nullptr};
};

wxIMPLEMENT_APP(app);

To Reproduce:

Run the compiled code sample, and then view CPU usage in task manager. Depending on how many cores you have, you'll see different usage values as wxWidgets only is allowed to use one core, but it's trying to use most of it.

Platform and version information

  • wxWidgets version you use: 3.3.1
  • wxWidgets port you use: wxMSW
  • OS and its version: Windows 10 21H2 (AMD64) build 19044.6218


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25797@github.com>

Quin Gillespie

unread,
Sep 15, 2025, 12:39:35 PM (10 days ago) Sep 15
to wx-...@googlegroups.com, Subscribed
trypsynth left a comment (wxWidgets/wxWidgets#25797)

Adding this:

	#ifdef __WXMSW__
		notebook->MSWDisableComposited();
	#endif

makes the behavior go away.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25797/3293039304@github.com>

VZ

unread,
Sep 15, 2025, 4:40:47 PM (9 days ago) Sep 15
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25797)

Probably not worth investigating in light of #25663.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25797/3293879069@github.com>

Quin Gillespie

unread,
Sep 15, 2025, 5:42:00 PM (9 days ago) Sep 15
to wx-...@googlegroups.com, Subscribed
trypsynth left a comment (wxWidgets/wxWidgets#25797)

Ah thanks, hadn't seen that. That should fix this :) thanks


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25797/3294057080@github.com>

VZ

unread,
Sep 17, 2025, 7:23:39 PM (7 days ago) Sep 17
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#25797)

Please check that #25808 fixes this if you can.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/25797/3304830543@github.com>

VZ

unread,
Sep 23, 2025, 9:40:51 AM (2 days ago) Sep 23
to wx-...@googlegroups.com, Subscribed

Closed #25797 as completed via b5a9fa3.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/25797/issue_event/19866966167@github.com>

Reply all
Reply to author
Forward
0 new messages