for all these features you'll need qt 5.14 · 2020. 1. 31. · how to profile a qt app on...
TRANSCRIPT
Testing&ProfilingQtonAndroid
BogDanVatră,ProgrammeratKDAB
It'sallaboutQt5.14!
p.2
Forallthesefeaturesyou'llneedQt5.14!
What'snewonQt5.14forAndroid?
What'snewonQt5.14forAndroid? p.3
What'snewonQt5.14forAndroid?
HowtouseQtTestonAndroid
HowtouseAVDsforrunningtests
HowtoprofileaQtapponAndroid
HowtouseaddresssanitizeronAndroid
Androidmultiarchbuildinonego
What'snewonQt5.14forAndroid? p.4
thebiggestfeatureaddedsinceImadetheQtonAndroidport
bydefaultallABIs(armeabi-v7a,arm64-v8,x86&x86_64)arebuilt
allowsyoutodecidewhichABI(s)youwanttobuildfor:
fromcommandline:$qmakeANDROID_ABIS="armeabi-v7aarm64-v8a"
AndroidAppBundles(aab)
What'snewonQt5.14forAndroid? p.5
AndroidAppBundles(aab)isthenew(preferred)waytodistributeyourappsonGooglePlay
generatesandservesoptimizedAPKsforeachuser’sdeviceconfiguration
supportsdynamicfeaturemodules,viaplaycorelibrary
fromcommandline:$makeaab
Seehttps://developer.android.com/guide/app-bundleformoreinfo
QtonAndroid5.14bringsmore
What'snewonQt5.14forAndroid? p.6
Sameasfor.aabyoucannowcreatean.apkfilefromcommandline:$makeapk
reworkedassetssupport:nowitlistsallthefilesandfolders.
loadQtpluginsdirectlyfromandroidlibsfolder
afewmore,checkhttps://www.kdab.com/qt-for-android-better-than-ever-before/formoreinfo
HowtouseQtTestonAndroid
HowtouseQtTestonAndroid p.7
What'snewonQt5.14forAndroid?
HowtouseQtTestonAndroid
HowtouseAVDsforrunningtests
HowtoprofileaQtapponAndroid
HowtouseaddresssanitizeronAndroid
Howdoweruntestsondesktop?
HowtouseQtTestonAndroid p.8
howdoweruntestsondesktop?$makecheck
HowdidweusedtoruntestsonAndroid?
HowtouseQtTestonAndroid p.9
usuallywedidn't
therewere(atleast?)twoscriptswhichusedtohelp
thesescriptsneverworkedproperly;(
Okayokay,but...
HowtouseQtTestonAndroid p.10
howshouldweruntestsonAndroid?$makecheck
...
HowtouseQtTestonAndroid p.11
ThisishowwearegoingtoruntestsonAndroidusingQt5.14:$makecheck
Yes,nowit'sthateasy!
Areyoukidding?!?!
HowtouseQtTestonAndroid p.12
25minutesjusttellustorun:$makecheck
Holdyourhorses...:)
HowtouseQtTestonAndroid p.13
ThereareafewAndroidspecificthingswhichyoureallyneedtoknow:
sayhellotoandroidtestrunner
howtobuild&runyourtestsefficiently
howtorunyourtestsonaspecificdevice/emulator
howtopassargumentstoandroidtestrunner
howtopassargumentstoyourtest
Sayhellotoandroidtestrunner
HowtouseQtTestonAndroid p.14
androidtestrunnerisanewtooladdedtoQt5.14which:
createsthe.apk(ifit'snotalreadycreated)
installsthe.apk
runsthefirstActivityfromAndroidManifest.xmluse--activityparametertospecifyanotherone
checksthetestresults
ifspecified,pullsthetestsoutputfilesinthebuildfolder
Beaware:multipleinstanceswillwaitforeachothertocomplete!
Howtobuild&runyourtestsefficiently
HowtouseQtTestonAndroid p.15
buildonlytheneededABIs
buildyourAPKsinparallel!
runthetests
1 $qmakeANDROID_ABIS="x86_64"2 $make-j$(nproc)apk3 $makecheck
Howtorunyourtestsonaspecificdevice
HowtouseQtTestonAndroid p.16
UseANDROID_DEVICE_SERIALenvironmentvariable
$ANDROID_DEVICE_SERIAL="emulator-5554"makecheck
Howtopassargumentstoandroidtestrunner
HowtouseQtTestonAndroid p.17
UseTESTARGSvariabletopassparamstoandroidtestrunner
$makeTESTARGS="--timeout600"check
Howtopassargumentstoyourtest
HowtouseQtTestonAndroid p.18
useTESTARGSvariabletopassparamstoandroidtestrunner
use--paramtopassparamstothetestitself
$makeTESTARGS="---oout.xml,xml-oout.txt,txt-o-,tap-vs"check
--followingparamswillbepasseddirectlytotestapp
-oout.xml,xmlstoresthetestsresultsinout.xml
-oout.txt,txtstoresthetestsresultsinout.txt
-o-,tapprints(tostdout)tapformat
-vsenablesloggingofeverysignalemission
out.xmlandout.txtarepulledbyandroidtestrunnertotestbuildfolder
HowtouseAVDsforrunningtests
HowtouseAVDsforrunningtests p.19
What'snewonQt5.14forAndroid?
HowtouseQtTestonAndroid
HowtouseAVDsforrunningtests
HowtoprofileaQtapponAndroid
HowtouseaddresssanitizeronAndroid
Plumbing
HowtouseAVDsforrunningtests p.20
usesdkmanagertoinstalltheemulatorandasystemimage$.../tools/bin/sdkmanager"emulator""system-images;android-29;default;x86_64"
useavdmanagertocreateanAVD$.../tools/bin/avdmanagercreateavd-ntest-k"system-images;android-29;default;x86_64"
choosecustomhardwareprofilechooseyesforhw.gpu.enabled
StartanAVD
HowtouseAVDsforrunningtests p.21
useemulatortool$.../tools/emulator-avdtest
pass--no-windowparamtoemulatorfordockerhosts
HowtoprofileaQtapponAndroid
HowtoprofileaQtapponAndroid p.22
What'snewonQt5.14forAndroid?
HowtouseQtTestonAndroid
HowtouseAVDsforrunningtests
HowtoprofileaQtapponAndroid
HowtouseaddresssanitizeronAndroid
HowtouseGoogletoolstodoprofiling
HowtoprofileaQtapponAndroid p.23
Whatwearegoingtocover:
howtouseNDKtoolstodoC/C++profiling
WhatweareNOTgoingtocover:
howtodoQMLprofiling
howtodoJavaprofiling
Steps:
HowtoprofileaQtapponAndroid p.24
build&installtheapplicationusingQtCreator
useNDKtoolstostartprofilerecording
starttheapplication
stoptheapplication
generateareportusingtheNDKtools
Build&installtheapplication
HowtoprofileaQtapponAndroid p.25
buildyourQt5.14app(inreleasemode)usingQtCreatorpreQt5.14stripsthe.sofilesinyourandroid-builddir,whichwillcasethereportsteptonotshowyouanysymbols
doNOTsignyourapplicationsigningtheapplicationwillremovethedebugablemanifestflag.
installtheapplicationonthetargetdevice
UseNDKtoolstostartprofilerecording
HowtoprofileaQtapponAndroid p.26
gotondk_folder/simpleperffolder
run./app_profiler.pytostartrecordingtheprofilingdata.Passatleast:--appparametertospecifythepackagename--libparametertospecifywhereisthebuilddirofyourapplicationformoreparameterspleasecheckhttps://android.googlesource.com/platform/system/extras/+/master/simpleperf/doc/android_application_profiling.md
$./app_profiler.py--apporg.qtproject.example.profile\--lib/home/bogdan/projects/build-profile-Release/android-build
Waitabituntiltheprofilerisreadyforrecording.
Start&stoptheapplication
HowtoprofileaQtapponAndroid p.27
starttheapplication
stoptheapplication
waituntil./app_profiler.pypullstherecordedprofiledata
GenerateareportusingtheNDKtools
HowtoprofileaQtapponAndroid p.28
Thereareacoupleofreportingtoolsinthatfolder,themostimportantonesare:
report.pyisawrapperoftheperfreportcommandonthehost#Reportcallgraph$./report.py-g
report_html.pygeneratesreport.htmlfilebasedontheprofilingdata#Generateinteractivechartstatistics,sampletableandflamegraphs,basedonperf.data$./report_html.py
Whattolookfor
HowtoprofileaQtapponAndroid p.29
qtMainLoopThreaisthethreadthatcallsyourmainfunctionusuallythisisthethreadthatyou'relookingfor
QtThread,QQmlThreadareQtinternalthreadsusedbyQmlEngine(Renderer)
RenderThread,Binder:XXXXXXareAndroidinternalthreads
unnamedthreadsusuallyareAndroidinternalthreads,butmightbeapplication'stoo
It'shighlyrecommendedtoexplicitlynameallyourapplicationthreads(useQThread::setObjectNamebeforeyoustartit)
HowtouseaddresssanitizeronAndroid
HowtouseaddresssanitizeronAndroid p.30
What'snewonQt5.14forAndroid?
HowtouseQtTestonAndroid
HowtouseAVDsforrunningtests
HowtoprofileaQtapponAndroid
HowtouseaddresssanitizeronAndroid
SamesupportasyoufindonGNU/Linux
HowtouseaddresssanitizeronAndroid p.31
firstclasssupportforaddresssanitizeronAndroidinQt5.14$qmakeCONFIG+=sanitizerCONFIG+=sanitize_address$makeapk
Yep,that'sallyouneedtodo!
Caveats:
itseemsitworksonlyonarm64-v8
itseemsitworksonlyonAndroid9+
itworkedformeonlyonGoogle'sPixel3