Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.

How To Profile QML App on Embedded Device: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Convert ExpressionEngine section headers)
(Add information on connection to a remote system)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}
 


[[Category:HowTo]]
[[Category:HowTo]]
[[Category:HowTo::Qt_Embedded]]
[[Category:HowTo::Qt_Embedded]]


[toc align_right="yes" depth="2"]


= How to profile QML app on embedded device =


Information on profiling QML app is scattered in places so I thought of putting it together in one place.
Information on profiling QML app is scattered in places so I thought of putting it together in one place.
Line 30: Line 28:
=== Steps for building app ===
=== Steps for building app ===


# Make sure that following options are added to the application's .pro file
1. Make sure that following options are added to the application's .pro file
<code>DEFINES ''= QMLJSDEBUGGER
<code>DEFINES ''= QMLJSDEBUGGER
DEFINES''= QT_DECLARATIVE_DEBUG
DEFINES''= QT_DECLARATIVE_DEBUG
CONFIG += declarative_debug</code>
CONFIG += declarative_debug</code>
# Ensure QTDIR refers to the installation path of QT for target as specified in _-prefix_
2. Ensure QTDIR refers to the installation path of QT for target as specified in _-prefix_
<code>e.g. QTDIR=/usr/local/qt-48x-emb<code>
<code>e.g. QTDIR=/usr/local/qt-48x-emb</code>
# Ensure PATH contains path of ''bin'' folder from installation path of Qt for target
3. Ensure PATH contains path of ''bin'' folder from installation path of Qt for target
</code>e.g. PATH=/usr/local/qt-48x-emb/bin:$PATH</code>
<code>e.g. PATH=/usr/local/qt-48x-emb/bin:$PATH</code>
# Generate make file using the .pro
4. Generate make file using the .pro
<code>host-cmd-prmt> qmake app.pro<code>
<code>host-cmd-prmt> qmake app.pro</code>
# Build the app
5. Build the app
</code>host-cmd-prmt> make</code>
<code>host-cmd-prmt> make</code>
# Transfer the app binaries and necessary app files to the target
6. Transfer the app binaries and necessary app files to the target


=== Launch QML Profiler (external) on host ===
=== Launch QML Profiler (external) on host ===
Line 48: Line 46:
# From the menu bar in QtCreator, select menu item '''''Analyze'''''-> '''''QML Profiler (External)'''''; this will popup a small dialog
# From the menu bar in QtCreator, select menu item '''''Analyze'''''-> '''''QML Profiler (External)'''''; this will popup a small dialog
# Note the '''''port''''' value. It will be passed on as command line option when launching the app
# Note the '''''port''''' value. It will be passed on as command line option when launching the app
# Detail instructions on profiling and interpreting the results can be found [http://doc.qt.io/qtcreator-2.7/creator-qml-performance-monitor.html here]
# Detail instructions on profiling and interpreting the results can be found [http://doc.qt.io/qtcreator/creator-qml-performance-monitor.html here]
# Hit the ''OK'' button after you launch the app on target
# Hit the ''OK'' button after you launch the app on target


Line 54: Line 52:


# Start the app on the target as,
# Start the app on the target as,
<code>target-prmt> app -platform eglfs -qmljsdebugger=port:3456<code>
<code>target-prmt> app -platform eglfs -qmljsdebugger=port:3456</code>


* Port value shall be same as that in the QML Profiler (External) Dialog
* Port value shall be same as that in the QML Profiler (External) Dialog
Line 65: Line 63:
* Make sure Qt libraries are copied on the target
* Make sure Qt libraries are copied on the target
* export LD_LIBRARY_PATH to refer to the path where Qt libraries are copied
* export LD_LIBRARY_PATH to refer to the path where Qt libraries are copied
</code>e.g. LD_LIBRARY_PATH=/usr/local/qt-48x-emb/lib:$LD_LIBRARY_PATH</code>
<code>e.g. LD_LIBRARY_PATH=/usr/local/qt-48x-emb/lib:$LD_LIBRARY_PATH</code>


=== Remote debugger plugin NOT found ===
=== Remote debugger plugin NOT found ===
Line 74: Line 72:
* On target, these libraries should be present in /usr/local/qt-48x-emb/plugins/qmltooling
* On target, these libraries should be present in /usr/local/qt-48x-emb/plugins/qmltooling
* export LD_LIBRARY_PATH to refer to the path where Qt plugin libraries are copied
* export LD_LIBRARY_PATH to refer to the path where Qt plugin libraries are copied
<code>e.g. LD_LIBRARY_PATH=/usr/local/qt-48x-emb/plugins/qmltooling:$LD_LIBRARY_PATH<code>
<code>e.g. LD_LIBRARY_PATH=/usr/local/qt-48x-emb/plugins/qmltooling:$LD_LIBRARY_PATH</code>


=== Cannot capture the logs on host in QML profiler ===
=== Cannot capture the logs on host in QML profiler ===


* Make sure you synchronize launching of the app on target and starting the profiling on host PC.
* Make sure you synchronize launching of the app on target and starting the profiling on host PC.
=== Connect to a remote system ===
It seems like it's not possible to enter an IP for a remote system. This can be solved by forwarding a local port. For Ubuntu (there are certainly solutions for other systems, too) you can do
<syntaxhighlight lang="bash">
sudo apt install netcat-traditional
nc.traditional -l -p 3768 -c "nc.traditional 192.168.0.10 3768"
</syntaxhighlight>
This will open a listening port on <code>3768</code>, and once QT Creator connects to it it will connect to <code>192.168.0.10</code> on port <code>3768</code>.

Latest revision as of 08:52, 14 September 2021



Information on profiling QML app is scattered in places so I thought of putting it together in one place.

Prerequisite

NOTE: Assumption is that Linux PC is used as development environment

  • Qt for host PC is installed. This is required to launch QtCreator
  • Make sure that option "-no-declarative-debug" was NOT specified when configuring Qt for target device
  • if Qt for target was configured with -prefix <installation-path> then make sure that same installation path exists on target

e.g. -prefix /usr/local/qt-48x-emb is specified then copy contents of /usr/local/qt-48x-emb from host to target at /usr/local/qt-48x-emb

  • Make sure Qt for target was built using same toolchain that will be used to build the app
  • Host PC (which will be running QtCreator) and target should be on same network

NOTE:

Profiling

At high level, to profile a QML app one will require to carry out following steps,

  1. Build the QML app to be profiled for target device
  2. Launch QML Profiler (external) from QtCreator on host
  3. Launch QML app on target with commandline options to enable remote profiling

Steps for building app

1. Make sure that following options are added to the application's .pro file

DEFINES ''= QMLJSDEBUGGER
DEFINES''= QT_DECLARATIVE_DEBUG
CONFIG += declarative_debug

2. Ensure QTDIR refers to the installation path of QT for target as specified in _-prefix_

e.g. QTDIR=/usr/local/qt-48x-emb

3. Ensure PATH contains path of bin folder from installation path of Qt for target

e.g. PATH=/usr/local/qt-48x-emb/bin:$PATH

4. Generate make file using the .pro

host-cmd-prmt> qmake app.pro

5. Build the app

host-cmd-prmt> make

6. Transfer the app binaries and necessary app files to the target

Launch QML Profiler (external) on host

  1. Launch QtCreator on host PC
  2. From the menu bar in QtCreator, select menu item Analyze-> QML Profiler (External); this will popup a small dialog
  3. Note the port value. It will be passed on as command line option when launching the app
  4. Detail instructions on profiling and interpreting the results can be found here
  5. Hit the OK button after you launch the app on target

Launch the app to be profiled on the target

  1. Start the app on the target as,
target-prmt> app -platform eglfs -qmljsdebugger=port:3456
  • Port value shall be same as that in the QML Profiler (External) Dialog
  • the app is run against eglfs platform plugin but it could run against any other platform plugin if that is tested to be run on the target.

Troubleshooting

Qt libraries not found

  • Make sure Qt libraries are copied on the target
  • export LD_LIBRARY_PATH to refer to the path where Qt libraries are copied
e.g. LD_LIBRARY_PATH=/usr/local/qt-48x-emb/lib:$LD_LIBRARY_PATH

Remote debugger plugin NOT found

  • Confirm if following libraries were built for target,
libqmldbg_tcp.so
libqmldbg_inspector.so
  • On target, these libraries should be present in /usr/local/qt-48x-emb/plugins/qmltooling
  • export LD_LIBRARY_PATH to refer to the path where Qt plugin libraries are copied
e.g. LD_LIBRARY_PATH=/usr/local/qt-48x-emb/plugins/qmltooling:$LD_LIBRARY_PATH

Cannot capture the logs on host in QML profiler

  • Make sure you synchronize launching of the app on target and starting the profiling on host PC.

Connect to a remote system

It seems like it's not possible to enter an IP for a remote system. This can be solved by forwarding a local port. For Ubuntu (there are certainly solutions for other systems, too) you can do

sudo apt install netcat-traditional
nc.traditional -l -p 3768 -c "nc.traditional 192.168.0.10 3768"

This will open a listening port on

3768

, and once QT Creator connects to it it will connect to

192.168.0.10

on port

3768

.