Skip to content

Commit 3c11ae7

Browse files
keithel-qtJason Mobarak
andauthored
QML profiling support and instructions (#730)
* Make profiling QML not require code modification This provides a -qmldebug command line option to the toolbox that sets up the QML debugger. * Improve README.md instructions for QML profiler. Co-authored-by: Jason Mobarak <[email protected]>
1 parent f444ba4 commit 3c11ae7

File tree

5 files changed

+254
-8
lines changed

5 files changed

+254
-8
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ installers/Linux/*.deb
2222
installers/Windows/NSIS/*
2323
!installers/Windows/NSIS/*.zip
2424
/.qt_for_python
25+
*.pyproject.user
26+
*.pyproject.bkup

README.md

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,46 @@ cargo make create-dist
141141
cargo make frontend-cpu-bench
142142
```
143143

144+
## QML Profiling
145+
146+
Download the universal Qt installer from qt.io. Run the installer, pick custom
147+
installation, and make sure that the Qt version installed matches the PySide2 or
148+
PySide6 version that is used for this project. Qt Creator will be automatically
149+
installed.
150+
151+
Once done, start the app using `cargo make run --qmldebug` or
152+
`cargo make qml-run --qmldebug`.
153+
154+
The application will indicate that the client application is waiting for a
155+
socket connection from the QML debugger. This is displayed to stderr.
156+
```QML Debugger: Waiting for connection on port 10002...```
157+
158+
Launch Qt Creator and load the project swift-toolbox.pyproject.
159+
160+
From the `Analyze` menu, choose `QML Profiler (Attach to waiting application)`.
161+
Connect to the same port that is shown in the shell you started the toolbox
162+
from.
163+
164+
The application should now start-up and can be used. Perform whatever actions
165+
for which you wish to capture profiling information. Qt Creator's Profiler pane
166+
will just be showing an elapsed timer counting up, with no information shown.
167+
This is expected.
168+
169+
When you are done performing actions in the application, either click the red
170+
"recording" circle button to stop the recording, or close the client
171+
application.
172+
173+
Upon doing this, Qt Creator's QML Profiling view should show profiling data.
174+
175+
You now have profiling data for the session you can comb through in the Qt
176+
Creator QML Profiling view that shows.
177+
144178
## QML Debugging
145179

146-
In order to enable QML debugging, add this block to the main.py file.
180+
In order to enable QML debugging, add the command line option `-qmldebug`.
147181
QML debugging does not entirely work currently for this project and
148-
still needs to be flushed out. See https://swift-nav.atlassian.net/browse/CPP-400
149-
```
150-
from PySide2.QtQml import QQmlDebuggingEnabler
182+
still needs to be fleshed out. See https://swift-nav.atlassian.net/browse/CPP-400
151183

152-
sys.argv.append("-qmljsdebugger=port:10002,block")
153-
debug = QQmlDebuggingEnabler() # pylint: disable=unused-variable
154-
```
155184
## Contributing
156185

157186
After making changes, run to tasks to ensure the code is ready for submission

console_backend/src/cli_options.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ pub struct CliOptions {
199199
/// Set the width of the main window.
200200
#[clap(long)]
201201
pub width: Option<u32>,
202+
203+
/// Enable QML Debugging and profiling.
204+
#[clap(long, hide = true)]
205+
pub qmldebug: bool,
202206
}
203207

204208
impl CliOptions {

swift-toolbox.pyproject

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
{
2+
"files": [
3+
"swiftnav_console/advanced_imu_tab.py",
4+
"swiftnav_console/advanced_magnetometer_tab.py",
5+
"swiftnav_console/advanced_networking_tab.py",
6+
"swiftnav_console/advanced_spectrum_analyzer_tab.py",
7+
"swiftnav_console/advanced_system_monitor_tab.py",
8+
"swiftnav_console/backend_importer.py",
9+
"swiftnav_console/backend_request_broker.py",
10+
"swiftnav_console/baseline_plot.py",
11+
"swiftnav_console/baseline_table.py",
12+
"swiftnav_console/connection.py",
13+
"swiftnav_console/console_resources.py",
14+
"swiftnav_console/constants.py",
15+
"swiftnav_console/file_io.py",
16+
"swiftnav_console/fusion_status_flags.py",
17+
"swiftnav_console/__init__.py",
18+
"swiftnav_console/logging_bar.py",
19+
"swiftnav_console/log_panel.py",
20+
"swiftnav_console/main.py",
21+
"swiftnav_console/observation_tab.py",
22+
"swiftnav_console/settings_tab.py",
23+
"swiftnav_console/solution_position_tab.py",
24+
"swiftnav_console/solution_table.py",
25+
"swiftnav_console/solution_velocity_tab.py",
26+
"swiftnav_console/status_bar.py",
27+
"swiftnav_console/tracking_signals_tab.py",
28+
"swiftnav_console/tracking_sky_plot_tab.py",
29+
"swiftnav_console/update_tab.py",
30+
31+
"resources/AdvancedTab.qml",
32+
"resources/BaselineTab.qml",
33+
"resources/ChartLegend.qml",
34+
"resources/ConnectionScreen.qml",
35+
"resources/console_resources.qrc",
36+
"resources/LoggingBar.qml",
37+
"resources/LogoPopup.qml",
38+
"resources/LogPanel.qml",
39+
"resources/MainDialogView.qml",
40+
"resources/MainTab.qml",
41+
"resources/MainTabs.qml",
42+
"resources/ObservationTab.qml",
43+
"resources/PositionLoopAnimation.qml",
44+
"resources/qtquickcontrols2.conf",
45+
"resources/SettingsTab.qml",
46+
"resources/SideNavBar.qml",
47+
"resources/SolutionTab.qml",
48+
"resources/StatusBar.qml",
49+
"resources/TabInfoBar.qml",
50+
"resources/TrackingTab.qml",
51+
"resources/UpdateNotifications.qml",
52+
"resources/UpdateTab.qml",
53+
"resources/view.qml",
54+
55+
"resources/AdvancedTabComponents/AdvancedImuTab.qml",
56+
"resources/AdvancedTabComponents/AdvancedInsTab.qml",
57+
"resources/AdvancedTabComponents/AdvancedMagnetometerTab.qml",
58+
"resources/AdvancedTabComponents/AdvancedNetworkingTab.qml",
59+
"resources/AdvancedTabComponents/AdvancedSpectrumAnalyzerTabChannelBar.qml",
60+
"resources/AdvancedTabComponents/AdvancedSpectrumAnalyzerTab.qml",
61+
"resources/AdvancedTabComponents/AdvancedSystemMonitorTabLeftPane.qml",
62+
"resources/AdvancedTabComponents/AdvancedSystemMonitorTab.qml",
63+
"resources/AdvancedTabComponents/DeviceMonitorAndResetDevice.qml",
64+
"resources/AdvancedTabComponents/DeviceMonitor.qml",
65+
"resources/AdvancedTabComponents/FusionStatusFlags.qml",
66+
"resources/AdvancedTabComponents/MessageBroadcaster.qml",
67+
"resources/AdvancedTabComponents/NetworkInfo.qml",
68+
"resources/AdvancedTabComponents/ObservationConnectionMonitor.qml",
69+
"resources/AdvancedTabComponents/OkStatus.qml",
70+
"resources/AdvancedTabComponents/ThreadStateTable.qml",
71+
"resources/AdvancedTabComponents/UnknownStatus.qml",
72+
"resources/AdvancedTabComponents/WarningStatus.qml",
73+
74+
"resources/BaseComponents/SmallCheckBox.qml",
75+
"resources/BaseComponents/SwiftButton.qml",
76+
"resources/BaseComponents/SwiftCategoryAxis.qml",
77+
"resources/BaseComponents/SwiftGroupBox.qml",
78+
"resources/BaseComponents/SwiftImage.qml",
79+
"resources/BaseComponents/SwiftTextbox.qml",
80+
"resources/BaseComponents/SwiftTextInput.qml",
81+
"resources/BaseComponents/SwiftValueAxis.qml",
82+
83+
"resources/BaselineTabComponents/BaselinePlot.qml",
84+
"resources/BaselineTabComponents/BaselineTable.qml",
85+
86+
"resources/Constants/Constants.qml",
87+
"resources/Constants/Globals.qml",
88+
"resources/Constants/qmldir",
89+
"resources/Constants/utils.js",
90+
91+
"resources/fonts/Roboto-Bold.ttf",
92+
"resources/fonts/RobotoCondensed-BoldItalic.ttf",
93+
"resources/fonts/RobotoCondensed-Bold.ttf",
94+
"resources/fonts/RobotoCondensed-Italic.ttf",
95+
"resources/fonts/RobotoCondensed-LightItalic.ttf",
96+
"resources/fonts/RobotoCondensed-Light.ttf",
97+
"resources/fonts/RobotoCondensed-Regular.ttf",
98+
"resources/fonts/Roboto-LICENSE.txt",
99+
"resources/fonts/Roboto-Regular.ttf",
100+
101+
"resources/images/ConnectionIcon.svg",
102+
"resources/images/icon.ico",
103+
"resources/images/icon.png",
104+
"resources/images/installer-side-panel.bmp",
105+
"resources/images/LogoBackground.jpg",
106+
"resources/images/README.md",
107+
"resources/images/splash.jpg",
108+
"resources/images/splash-version.jpg",
109+
"resources/images/swiftLogoWide.svg",
110+
111+
"resources/images/fontawesome/bars-solid.svg",
112+
"resources/images/fontawesome/braille-solid.svg",
113+
"resources/images/fontawesome/chevron-circle-up-solid.svg",
114+
"resources/images/fontawesome/circle-solid.svg",
115+
"resources/images/fontawesome/cogs-solid.svg",
116+
"resources/images/fontawesome/crosshairs-solid.svg",
117+
"resources/images/fontawesome/download.svg",
118+
"resources/images/fontawesome/eraser-solid.svg",
119+
"resources/images/fontawesome/exclamation-triangle-solid.svg",
120+
"resources/images/fontawesome/exclamation-triangle.svg",
121+
"resources/images/fontawesome/expand-solid.svg",
122+
"resources/images/fontawesome/file-export.svg",
123+
"resources/images/fontawesome/file-import.svg",
124+
"resources/images/fontawesome/floppy-o.svg",
125+
"resources/images/fontawesome/folder-open-regular.svg",
126+
"resources/images/fontawesome/folder-regular.svg",
127+
"resources/images/fontawesome/folder-solid.svg",
128+
"resources/images/fontawesome/info-circle-solid.svg",
129+
"resources/images/fontawesome/LICENSE.txt",
130+
"resources/images/fontawesome/lock-solid.svg",
131+
"resources/images/fontawesome/map-marker-alt-solid.svg",
132+
"resources/images/fontawesome/pause-circle-regular.svg",
133+
"resources/images/fontawesome/pause-solid.svg",
134+
"resources/images/fontawesome/play-solid.svg",
135+
"resources/images/fontawesome/power27.svg",
136+
"resources/images/fontawesome/power-off-solid.svg",
137+
"resources/images/fontawesome/README.md",
138+
"resources/images/fontawesome/refresh_blue.svg",
139+
"resources/images/fontawesome/refresh.svg",
140+
"resources/images/fontawesome/satellite-solid.svg",
141+
"resources/images/fontawesome/square-solid.svg",
142+
"resources/images/fontawesome/stop.svg",
143+
"resources/images/fontawesome/table-solid.svg",
144+
"resources/images/fontawesome/upload.svg",
145+
146+
"resources/images/iconic/AUTHORS",
147+
"resources/images/iconic/fullscreen.svg",
148+
"resources/images/iconic/LICENSE",
149+
"resources/images/iconic/media-pause.svg",
150+
"resources/images/iconic/move.svg",
151+
"resources/images/iconic/pause.svg",
152+
"resources/images/iconic/play.svg",
153+
"resources/images/iconic/stop.svg",
154+
"resources/images/iconic/target.svg",
155+
"resources/images/iconic/x.svg",
156+
157+
"resources/images/swift-nav/Advanced.svg",
158+
"resources/images/swift-nav/Baseline.svg",
159+
"resources/images/swift-nav/Connection.svg",
160+
"resources/images/swift-nav/Observations.svg",
161+
"resources/images/swift-nav/Settings.svg",
162+
"resources/images/swift-nav/Solution.svg",
163+
"resources/images/swift-nav/Tracking.svg",
164+
"resources/images/swift-nav/Update.svg",
165+
166+
"resources/LogoPopupComponents/AboutMe.qml",
167+
"resources/LogoPopupComponents/Licenses.qml",
168+
169+
"resources/ObservationTabComponents/ObservationFilterColumn.qml",
170+
"resources/ObservationTabComponents/ObservationTable.qml",
171+
172+
"resources/SettingsTabComponents/InsSettingsPopup.qml",
173+
"resources/SettingsTabComponents/SettingsPane.qml",
174+
"resources/SettingsTabComponents/SettingsTable.qml",
175+
176+
"resources/SideNavBarComponents/SideNavButton.qml",
177+
178+
"resources/SolutionPlotCommon/SolutionPlotLoop.js",
179+
180+
"resources/SolutionTabComponents/SolutionPositionTab.qml",
181+
"resources/SolutionTabComponents/SolutionTable.qml",
182+
"resources/SolutionTabComponents/SolutionVelocityTab.qml",
183+
184+
"resources/styles/SwiftNav/Button.qml",
185+
"resources/styles/SwiftNav/ComboBox.qml",
186+
"resources/styles/SwiftNav/Label.qml",
187+
"resources/styles/SwiftNav/qmldir",
188+
"resources/styles/SwiftNav/RoundButton.qml",
189+
"resources/styles/SwiftNav/TabBar.qml",
190+
"resources/styles/SwiftNav/TabButton.qml",
191+
192+
"resources/TableComponents/SortableColumnHeading.qml",
193+
"resources/TableComponents/SwiftTableView.qml",
194+
"resources/TableComponents/TableCellDelegate.qml",
195+
196+
"resources/TrackingTabComponents/TrackingSignalsTab.qml",
197+
"resources/TrackingTabComponents/TrackingSkyPlotTab.qml",
198+
199+
"resources/UpdateTabComponents/FileIOSelectLocalFileAndDestPath.qml",
200+
"resources/UpdateTabComponents/FirmwareDownload.qml",
201+
"resources/UpdateTabComponents/FirmwareRevision.qml",
202+
"resources/UpdateTabComponents/FirmwareVersionAndDownloadLabels.qml",
203+
"resources/UpdateTabComponents/FirmwareVersion.qml",
204+
"resources/UpdateTabComponents/SelectFirmwareDownloadDirectory.qml",
205+
"resources/UpdateTabComponents/SelectLocalFile.qml"
206+
]
207+
}

swiftnav_console/main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from PySide6.QtGui import QFontDatabase, QIcon, QPixmap
2424

25-
from PySide6.QtQml import QQmlComponent, qmlRegisterType
25+
from PySide6.QtQml import QQmlComponent, qmlRegisterType, QQmlDebuggingEnabler
2626

2727
from PySide6.QtQuickControls2 import QQuickStyle
2828

@@ -703,6 +703,7 @@ def main(passed_args: Optional[Tuple[str, ...]] = None) -> int:
703703
parser.add_argument("--show-csv-log", action="store_true")
704704
parser.add_argument("--height", type=int)
705705
parser.add_argument("--width", type=int)
706+
parser.add_argument("--qmldebug", action="store_true")
706707

707708
args_main, unknown_args = parser.parse_known_args()
708709
if args_main.debug_with_no_backend and args_main.read_capnp_recording is None:
@@ -722,6 +723,9 @@ def main(passed_args: Optional[Tuple[str, ...]] = None) -> int:
722723
else:
723724
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
724725
QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
726+
if args_main.qmldebug:
727+
sys.argv.append("-qmljsdebugger=port:10002,block")
728+
debug = QQmlDebuggingEnabler() # pylint: disable=unused-variable
725729
app = QApplication(sys.argv)
726730
app.setWindowIcon(QIcon(":/images/icon.ico"))
727731
app.setOrganizationName(ApplicationMetadata.ORGANIZATION_NAME)

0 commit comments

Comments
 (0)