Skip to content

Avoid hidden network traffic graph updates - #805

Merged
hebasto merged 2 commits into
bitcoin-core:qt6from
johnny9:fix/network-traffic-selected-only
Jul 24, 2026
Merged

Avoid hidden network traffic graph updates#805
hebasto merged 2 commits into
bitcoin-core:qt6from
johnny9:fix/network-traffic-selected-only

Conversation

@johnny9

@johnny9 johnny9 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • move network traffic sampling, smoothing, and history retention onto an owned worker thread
  • publish immutable traffic snapshots back to the GUI thread only while the Network Traffic page is active
  • retain raw samples while hidden and rebuild the requested range when the page becomes active again
  • lazy-load the Network Traffic settings page so its graphs do not exist while another settings section is selected
  • preserve byte totals as 64-bit values
  • rename the native graph gradient property so it no longer shadows QQuickPaintedItem::fillColor
  • add C++ and QML coverage for thread affinity, hidden-page suppression, retained history, range changes, page lifecycle, and destruction while active

Why

The previous timer was moved to a background thread, but its timeout updated a GUI-thread model every second regardless of whether the Network Traffic page was visible. That kept smoothing, full-history copies, signal delivery, and graph bindings active in the background. Timer/thread ownership was also not explicit during shutdown.

This keeps the inexpensive raw sample collection running off-thread while avoiding hidden GUI work and making worker shutdown deterministic.

LineGraph also declared its own fillColor property over the property inherited from QQuickPaintedItem, producing a QML property-cache warning. The native property is now named gradientColor; the public NetworkTrafficGraph.fillColor API and rendering behavior are unchanged.

User impact

Opening Network Traffic still shows the samples collected while the page was hidden, and changing the graph range rebuilds the visible history without losing totals. Other settings pages no longer pay for traffic graph updates or retain the graph objects.

Issue

Fixes #611.

Fixes #801.

Graph reset behavior was split from #611 into #806 and is intentionally not included here.

Validation

  • full RelWithDebInfo build with app tests enabled
  • qmllint -I qml -I test/mocks/qml qml/components/NetworkTrafficGraph.qml qml/pages/node/NetworkTraffic.qml qml/pages/node/NodeSettings.qml test/qml/tst_nodesettings.qml
  • bitcoinqml_qmltests: 380 passed, 0 failed
  • NetworkTrafficTowerTests: 6 passed, 0 failed
  • git diff --check origin/qt6...HEAD

The aggregate unit executable was also run locally. Its Network Traffic suite passed; unrelated existing OptionsModel tests could not write the default Bitcoin data directory inside the managed filesystem sandbox.

@johnny9
johnny9 marked this pull request as ready for review July 22, 2026 16:02
@johnny9 johnny9 changed the title qml: avoid hidden network traffic updates Avoid hidden network traffic graph updates Jul 22, 2026

@jarolrod jarolrod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 35fecc9

Sampling stays on the worker, GUI publish is gated on page activity

Tested manually

@hebasto
hebasto merged commit c238cef into bitcoin-core:qt6 Jul 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LineGraph::fillColor shadows a member of the base class Network traffic: harden graph updates and preserve range state

3 participants