Adding interstitial ads to a QT application on Android platform

I keep working on my Lines Game and probably I try to make it the best Lines Game in the world, but there is some disappointing incident that prevents it from being the best and makes it a usual game that glitches a bit. To see the glitch in action download the beta version of the game.

Adding Interstitial Ads to a QT application on Android platform is an interesting and relatively exciting job. I learned the following facts while doing it:

  1. To build my app with Google Play Services I add com.google.android.gms:play-services-ads:18.1.1 dependency to build.gradle and add com.google.android.gms.version and com.google.android.gms.ads.APPLICATION_ID to the manifest.
  2. I do not specify additional permissions (uses-permission attributes INTERNET, WRITE_EXTERNAL_STORAGE, ACCESS_NETWORK_STATE) required by ads, but they are detected automatically when I upload the app to Google Play store and the used is not prompted to allow them when the app starts.
  3. QT main thread (on which QML UI is run) is not Android UI thread. So I cannot call Java advertising API from QML or C++ directly, but all the calls should be queued with runOnUiThread method.
  4. To access Context required by Java advertising API I replace QtActivity with my own custom activity that implements all the advertising logic and forwards all the lifecycle events to original QtActivity.
  5. When the interstitial ad is open my activity is paused and stopped (onPaused / onStopped event handlers are called in Java and onApplicationStateChanged with Qt::ApplicationInactive / Qt::ApplicationSuspended respectively ) and when the interstitial ad is closed my activity is resumed but in different ways either with onRestart.

That all is great, but there is the glitch that I can stably reproduce on my Redme 6 Pro phone where 64-bit app is installed (but not on other 32-bit phone or an emulator) with the following steps:

  1. Do a clean install of the app from the store (not via USB with ADB).
  2. Wait 30 seconds and press ‘New game’ button that results in opening the interstitial ad.
  3. Deactivate the app.
  4. Activate the app back by clicking on the application icon and you will see a gray screen with the app logo image and the app name at the upper left corner and the following the logs:
adb logcat | egrep -i 'InterstitialAdWrapper|Lines|Линии|error|exception'
09-04 21:10:55.123 18730 18730 D InterstitialAdWrapper: In the onCreate() event
09-04 21:10:55.127 18730 18730 D InterstitialAdWrapper: Initializing the Mobile Ads SDK...
09-04 21:10:55.310 18730 18730 D InterstitialAdWrapper: Creating InterstitialAd...
09-04 21:10:55.311 18730 18730 D InterstitialAdWrapper: Loading on UI thread...
09-04 21:10:55.311 18730 18730 D InterstitialAdWrapper: Loading InterstitialAd...
09-04 21:10:55.412 18730 18730 D InterstitialAdWrapper: In the onStart() event
09-04 21:10:55.414 18730 18730 D InterstitialAdWrapper: In the onResume() event
09-04 21:10:55.423 18730 18802 E FA      : Scheduler not set. Not logging error/warn
09-04 21:10:55.425 18730 18802 I FA      :   adb shell setprop debug.firebase.analytics.app net.geographx.LinesGame
09-04 21:10:55.439 18798 18798 I dex2oat : /system/bin/dex2oat -j6 --dex-file=/data/data/net.geographx.LinesGame/cache/1557357152169.jar --output-vdex-fd=53 --oat-fd=54 --oat-location=/data/data/net.geographx.LinesGame/cache/oat/arm64/1557357152169.odex --compiler-filter=quicken --class-loader-context=&
09-04 21:10:55.793  2089  2283 I ActivityManager: Displayed net.geographx.LinesGame/net.geographx.MainActivity: +2s373ms (total +19s860ms)
09-04 21:10:55.794  2089  2283 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{cddd628 u0 net.geographx.LinesGame/net.geographx.MainActivity t554} time:23136219
09-04 21:10:55.801  2089  2276 W System.err: java.io.FileNotFoundException: /acct/uid_10013/pid_17550/cgroup.procs (No such file or directory)
09-04 21:10:55.809 18730 18786 D libLinesGameQt.so: Translation file has been loaded successfully:  "LinesGame_ru"
09-04 21:10:55.810 18730 18786 D Линии: App version:  "2.5.0, #74"
09-04 21:10:55.825 18730 18786 D Линии: QT/SysInfo: Device Pixel Ratio: 2.99861  Screen DPI:  134.686
09-04 21:10:55.831 18730 18836 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/qml/QtQuick.2/libqtquick2plugin.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:55.839  2089  3557 I ActivityManager: Start proc 18840:com.android.chrome:webview_service/u0a67 for service com.android.chrome/org.chromium.android_webview.services.VariationsSeedServer caller=net.geographx.LinesGame
09-04 21:10:55.845 18730 18836 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:55.873 18730 18836 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/qml/QtQuick/Layouts/libqquicklayoutsplugin.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:55.878 18730 18836 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/qml/QtQuick/Dialogs/libdialogplugin.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:55.891 18730 18836 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/qml/QtQuick/Templates.2/libqtquicktemplates2plugin.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:55.911 18730 18836 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/qml/QtQuick/Window.2/libwindowplugin.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:55.967  2089  2278 I chatty  : uid=1000(system) ActivityManager identical 6 lines
09-04 21:10:55.974  2089  2332 W InputDispatcher: channel 'eaacf1 com.android.settings/com.android.settings.SubSettings (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
09-04 21:10:55.975  2089  2332 W InputDispatcher: channel '16df15c com.android.settings/com.android.settings.SubSettings (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
09-04 21:10:55.975  2089  2332 W InputDispatcher: channel '28be304 com.android.settings/com.android.settings.MainSettings (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
09-04 21:10:55.975  2089  2332 W InputDispatcher: channel 'b9a542f com.android.settings/com.android.settings.SubSettings (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
09-04 21:10:55.975  2089  2332 W InputDispatcher: channel 'bae7f15 com.android.settings/com.android.settings.SubSettings (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
09-04 21:10:55.978  2089  2332 W InputDispatcher: channel 'eb36ba0 com.android.settings/com.android.settings.MainSettings (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
09-04 21:10:56.021 18730 18786 D Линии: InterstitialAdWrapper  valid
09-04 21:10:56.072  2089  2841 W System.err: java.io.FileNotFoundException: /acct/uid_10067/pid_18840/cgroup.procs (No such file or directory)
09-04 21:10:56.117 18730 18786 D Линии: "Error loading game: "
09-04 21:10:56.117 18730 18786 D Линии: of type BasicException:  "Cannot open file '/data/user/0/net.geographx.LinesGame/files/CurrentGame.dat' for reading."
09-04 21:10:56.160   721  3946 E ACDB-LOADER: Error: ACDB_CMD_GET_AFE_COMMON_TABLE_SIZE Returned = -19
09-04 21:10:56.160   721  3946 E ACDB-LOADER: Error: ACDB AFE returned = -19
09-04 21:10:56.163  1056 11539 I chatty  : uid=1041(audioserver) Binder:1056_7 identical 2 lines
09-04 21:10:56.177 18730 18786 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqgif.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:56.181 18730 18786 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqicns.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:56.183 18730 18786 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqico.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:56.185 18730 18786 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqjpeg.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:56.187 18730 18786 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqsvg.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:56.189 18730 18786 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqtga.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:56.192 18730 18786 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqtiff.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:56.194 18730 18786 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqwbmp.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:56.195 18730 18786 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqwebp.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:10:56.205 18730 18730 W ResourceType: Failure getting entry for 0x7f130532 (t=18 e=1330) (error -2147483647)
09-04 21:10:56.210  2089  3259 I ActivityManager: Start proc 18872:com.android.chrome:sandboxed_process0/u0i36 for webview_service net.geographx.LinesGame/org.chromium.content.app.SandboxedProcessService0 caller=net.geographx.LinesGame
09-04 21:10:56.290 18730 18730 E chromium: [ERROR:filesystem_posix.cc(89)] stat /data/user/0/net.geographx.LinesGame/cache/WebView/Crashpad: No such file or directory (2)
09-04 21:10:56.291 18730 18730 E chromium: [ERROR:filesystem_posix.cc(62)] mkdir /data/user/0/net.geographx.LinesGame/cache/WebView/Crashpad: No such file or directory (2)
09-04 21:10:56.334 18872 18872 D         : Regionalization Environment load packages for Carrier error!
09-04 21:10:56.398 18730 18730 W raphx.LinesGame: type=1400 audit(0.0:4665): avc: denied { read } for name="vmstat" dev="proc" ino=4026532118 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:proc:s0 tclass=file permissive=0
09-04 21:10:56.463 18872 18872 D ThemeCompatibility: getVersion(): /data/system/theme_config/theme_compatibility.xml  java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml (No such file or directory)
09-04 21:10:56.464 18872 18872 W System.err: java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml (No such file or directory)
09-04 21:10:56.591 18872 18872 W PackageManager: Failure retrieving text 0x7f0c001f in package net.geographx.LinesGame
09-04 21:10:56.591 18872 18872 W PackageManager: java.lang.NullPointerException: Attempt to invoke virtual method 'void miui.content.res.ThemeResourcesSystem.mergeThemeValues(java.lang.String, miui.content.res.ThemeValues)' on a null object reference
09-04 21:10:56.832  2089  3258 W System.err: java.io.FileNotFoundException: /acct/uid_99036/pid_18872/cgroup.procs (No such file or directory)
09-04 21:10:57.211 18730 18786 W Линии: QQmlExpression: Expression qrc:/OptionsPage.qml:215:21 depends on non-NOTIFYable properties:
09-04 21:10:57.211 18730 18786 W Линии:     Squircle::firstRunFlag
09-04 21:10:57.211 18730 18786 W Линии: QQmlExpression: Expression qrc:/OptionsPage.qml:208:21 depends on non-NOTIFYable properties:
09-04 21:10:57.211 18730 18786 W Линии:     Squircle::firstRunFlag
09-04 21:10:57.268 18730 18786 W Линии: QQmlExpression: Expression qrc:/ControlsHelpPage.qml:149:17 depends on non-NOTIFYable properties:
09-04 21:10:57.268 18730 18786 W Линии:     Squircle::firstRunFlag
09-04 21:10:57.297 18730 18786 W Линии: QQmlExpression: Expression qrc:/HowToPlayPage.qml:83:17 depends on non-NOTIFYable properties:
09-04 21:10:57.297 18730 18786 W Линии:     Squircle::firstRunFlag
09-04 21:10:57.305 18730 18786 W Линии: qrc:/HowToPlayPage.qml:71:37: QML ScrollBar: Possible anchor loop detected on horizontal anchor.
09-04 21:10:57.327 18730 18786 D Линии: Starting the application event loop...
09-04 21:10:57.496 18730 18786 D Линии: onApplicationStateChanged(Qt::ApplicationActive)
09-04 21:10:58.880 18730 18730 D InterstitialAdWrapper: onAdLoaded
09-04 21:10:58.880 18730 18730 D Линии: InterstitialAdWrapper Native Loaded.
09-04 21:11:09.937   721  3946 E ACDB-LOADER: Error: ACDB_CMD_GET_AFE_COMMON_TABLE_SIZE Returned = -19
09-04 21:11:09.937   721  3946 E ACDB-LOADER: Error: ACDB AFE returned = -19
09-04 21:11:12.893  1056 11539 I chatty  : uid=1041(audioserver) Binder:1056_7 identical 2 lines
09-04 21:11:22.500  1056 22279 I chatty  : uid=1041(audioserver) Binder:1056_C identical 2 lines
09-04 21:11:29.271  1056 11539 I chatty  : uid=1041(audioserver) Binder:1056_7 identical 2 lines
09-04 21:11:31.103 18074 18074 I chatty  : uid=10040(com.android.browser) identical 3 lines
09-04 21:11:31.768  1056 11539 I chatty  : uid=1041(audioserver) Binder:1056_7 identical 2 lines
09-04 21:11:37.524   721  3946 E ACDB-LOADER: Error: ACDB_CMD_GET_AFE_COMMON_TABLE_SIZE Returned = -19
09-04 21:11:37.524   721  3946 E ACDB-LOADER: Error: ACDB AFE returned = -19
09-04 21:11:37.859  1056 11539 I chatty  : uid=1041(audioserver) Binder:1056_7 identical 3 lines
09-04 21:11:40.590  2089  2379 W System.err: java.io.FileNotFoundException: /acct/uid_10013/pid_17550/cgroup.procs (No such file or directory)
09-04 21:11:40.643  2089  2841 W System.err: java.io.FileNotFoundException: /acct/uid_10013/pid_17550/cgroup.procs (No such file or directory)
09-04 21:11:42.934   760   760 W HwcComposer: command 0x3000000 generated error 3
09-04 21:11:44.255  1056 20227 I chatty  : uid=1041(audioserver) Binder:1056_E identical 2 lines
09-04 21:12:02.146   721  3946 E ACDB-LOADER: Error: ACDB_CMD_GET_AFE_COMMON_TABLE_SIZE Returned = -19
09-04 21:12:02.146   721  3946 E ACDB-LOADER: Error: ACDB AFE returned = -19
09-04 21:12:03.384  1056 11539 I chatty  : uid=1041(audioserver) Binder:1056_7 identical 2 lines
09-04 21:12:12.101  2089  2379 W System.err: java.io.FileNotFoundException: /acct/uid_10013/pid_17550/cgroup.procs (No such file or directory)
09-04 21:12:12.115  2089  2456 W System.err: java.io.FileNotFoundException: /acct/uid_10013/pid_17550/cgroup.procs (No such file or directory)
09-04 21:12:16.367   721  3946 E ACDB-LOADER: Error: ACDB_CMD_GET_AFE_COMMON_TABLE_SIZE Returned = -19
09-04 21:12:16.367   721  3946 E ACDB-LOADER: Error: ACDB AFE returned = -19
09-04 21:12:18.449  1056 20227 I chatty  : uid=1041(audioserver) Binder:1056_E identical 2 lines
09-04 21:12:48.213  1042  1164 I chatty  : uid=1000(system) HwBinder:1042_1 identical 49 lines
09-04 21:12:57.004 18730 18786 D Линии: InterstitialAdWrapper  calling show from C++
09-04 21:12:57.004 18730 18786 D Линии: InterstitialAdWrapper  valid
09-04 21:12:57.005 18730 18786 D InterstitialAdWrapper: Calling 'Show' on UI thread...
09-04 21:12:57.045 18730 18730 D InterstitialAdWrapper: Showing...
09-04 21:12:57.067  2089  3259 I ActivityManager: START u0 {cmp=net.geographx.LinesGame/com.google.android.gms.ads.AdActivity (has extras)} from uid 10168
09-04 21:12:57.074  2089  3259 D ActivityTrigger: activityStartTrigger: Activity is Triggerred in full screen ApplicationInfo{a68a94f net.geographx.LinesGame}
09-04 21:12:57.074  2089  3259 E ActivityTrigger: activityStartTrigger: not whiteListednet.geographx.LinesGame/com.google.android.gms.ads.AdActivity/74
09-04 21:12:57.075  2089  3259 D ActivityTrigger: activityResumeTrigger: The activity in ApplicationInfo{a68a94f net.geographx.LinesGame} is now in focus and seems to be in full-screen mode
09-04 21:12:57.075  2089  3259 E ActivityTrigger: activityResumeTrigger: not whiteListednet.geographx.LinesGame/com.google.android.gms.ads.AdActivity/74
09-04 21:12:57.081 18730 18730 D InterstitialAdWrapper: In the onPause() event
09-04 21:12:57.084  2089  3258 D ActivityTrigger: activityResumeTrigger: The activity in ApplicationInfo{a68a94f net.geographx.LinesGame} is now in focus and seems to be in full-screen mode
09-04 21:12:57.084  2089  3258 E ActivityTrigger: activityResumeTrigger: not whiteListednet.geographx.LinesGame/com.google.android.gms.ads.AdActivity/74
09-04 21:12:57.087  3268  3446 I WtProcessController: MOVE TO FOREGROUND: net.geographx.LinesGame 10168
09-04 21:12:57.087  3268  3446 I WtProcessController: FOREGROUND INFO: name=net.geographx.LinesGame uid=10168 pid=18730 TaskId:554
09-04 21:12:57.112 18730 18730 D InterstitialAdWrapper: onAdOpened
09-04 21:12:57.112 18730 18786 D Линии: onApplicationStateChanged(Qt::ApplicationInactive)
09-04 21:12:57.112 18730 18730 D Линии: InterstitialAdWrapper Native Opened.
09-04 21:12:57.281  2089  2283 I ActivityManager: Displayed net.geographx.LinesGame/com.google.android.gms.ads.AdActivity: +187ms
09-04 21:12:57.282  2089  2283 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{ac81829 u0 net.geographx.LinesGame/com.google.android.gms.ads.AdActivity t554} time:23257707
09-04 21:13:01.236  2089  2332 W System.err: java.io.FileNotFoundException: /acct/uid_10018/pid_3316/cgroup.procs (No such file or directory)
09-04 21:13:01.246  2089  2332 W System.err: java.io.FileNotFoundException: /acct/uid_10168/pid_18730/cgroup.procs (No such file or directory)
09-04 21:13:01.247  2089  2332 W System.err: java.io.FileNotFoundException: /acct/uid_99036/pid_18872/cgroup.procs (No such file or directory)
09-04 21:13:01.249  2089  2332 W System.err: java.io.FileNotFoundException: /acct/uid_1000/pid_5797/cgroup.procs (No such file or directory)
09-04 21:13:01.352  2089  2278 I chatty  : uid=1000(system) ActivityManager identical 4 lines
09-04 21:13:01.363   759   759 E lowmemorykiller: Error writing /proc/6111/oom_score_adj; errno=22
09-04 21:13:01.367  2089  2456 W ActivityManager: Exception when unbinding service com.android.chrome/org.chromium.content.app.PrivilegedProcessService0
09-04 21:13:01.367  2089  2456 W ActivityManager: android.os.DeadObjectException
09-04 21:13:01.713  2089  2276 W System.err: java.io.FileNotFoundException: /acct/uid_10168/pid_18730/cgroup.procs (No such file or directory)
09-04 21:13:01.719  2089  2276 W System.err: java.io.FileNotFoundException: /acct/uid_99036/pid_18872/cgroup.procs (No such file or directory)
09-04 21:13:01.721 18730 18730 D InterstitialAdWrapper: In the onStop() event
09-04 21:13:01.729   760   831 E BufferQueueProducer: [SurfaceView - net.geographx.LinesGame/net.geographx.MainActivity#0] disconnect: not connected (req=1)
09-04 21:13:01.739 18730 18786 D Линии: onApplicationStateChanged(Qt::ApplicationSuspended)
09-04 21:13:04.975  2089  3598 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=net.geographx.LinesGame/net.geographx.MainActivity bnds=[74,1610][242,1778] (has extras)} from uid 10018
09-04 21:13:04.988  2089  3598 D ActivityTrigger: activityResumeTrigger: The activity in ApplicationInfo{a68a94f net.geographx.LinesGame} is now in focus and seems to be in full-screen mode
09-04 21:13:04.988  2089  3598 E ActivityTrigger: activityResumeTrigger: not whiteListednet.geographx.LinesGame/com.google.android.gms.ads.AdActivity/74
09-04 21:13:04.995  2089  3598 D ActivityTrigger: activityStartTrigger: Activity is Triggerred in full screen ApplicationInfo{a68a94f net.geographx.LinesGame}
09-04 21:13:04.995  2089  3598 E ActivityTrigger: activityStartTrigger: not whiteListednet.geographx.LinesGame/net.geographx.MainActivity/74
09-04 21:13:04.996  2089  3598 D ActivityTrigger: activityResumeTrigger: The activity in ApplicationInfo{a68a94f net.geographx.LinesGame} is now in focus and seems to be in full-screen mode
09-04 21:13:04.996  2089  3598 E ActivityTrigger: activityResumeTrigger: not whiteListednet.geographx.LinesGame/net.geographx.MainActivity/74
09-04 21:13:05.006  2089  3598 D ActivityTrigger: activityResumeTrigger: The activity in ApplicationInfo{a68a94f net.geographx.LinesGame} is now in focus and seems to be in full-screen mode
09-04 21:13:05.006  2089  3598 E ActivityTrigger: activityResumeTrigger: not whiteListednet.geographx.LinesGame/net.geographx.MainActivity/74
09-04 21:13:05.010  2089  3598 W System.err: java.io.FileNotFoundException: /acct/uid_10168/pid_18730/cgroup.procs (No such file or directory)
09-04 21:13:05.012  2089  3598 W System.err: java.io.FileNotFoundException: /acct/uid_10018/pid_3316/cgroup.procs (No such file or directory)
09-04 21:13:05.014  2089  3598 W System.err: java.io.FileNotFoundException: /acct/uid_99036/pid_18872/cgroup.procs (No such file or directory)
09-04 21:13:05.016  3268  3446 I WtProcessController: MOVE TO FOREGROUND: net.geographx.LinesGame 10168
09-04 21:13:05.016  3268  3446 I WtProcessController: FOREGROUND INFO: name=net.geographx.LinesGame uid=10168 pid=18730 TaskId:554
09-04 21:13:05.046 18730 18730 D InterstitialAdWrapper: In the onCreate() event
09-04 21:13:05.047 18730 18730 D InterstitialAdWrapper: Initializing the Mobile Ads SDK...
09-04 21:13:05.048 18730 18730 D InterstitialAdWrapper: Creating InterstitialAd...
09-04 21:13:05.048 18730 18730 D InterstitialAdWrapper: Loading on UI thread...
09-04 21:13:05.048 18730 18730 D InterstitialAdWrapper: Loading InterstitialAd...
09-04 21:13:05.093 18730 18730 D InterstitialAdWrapper: In the onStart() event
09-04 21:13:05.099 18730 18730 D InterstitialAdWrapper: In the onResume() event
09-04 21:13:05.165  2089  2283 I ActivityManager: Displayed net.geographx.LinesGame/net.geographx.MainActivity: +151ms
09-04 21:13:05.476  2089  2283 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{8492fd4 u0 net.geographx.LinesGame/net.geographx.MainActivity t554} time:23265901
09-04 21:13:05.500  2089  2276 W System.err: java.io.FileNotFoundException: /acct/uid_10018/pid_3316/cgroup.procs (No such file or directory)
09-04 21:13:05.511  2089  2276 W System.err: java.io.FileNotFoundException: /acct/uid_1000/pid_5797/cgroup.procs (No such file or directory)
09-04 21:13:06.751 18730 18730 D InterstitialAdWrapper: onAdLoaded
09-04 21:13:06.751 18730 18730 D Линии: InterstitialAdWrapper Native Loaded.

When I terminate and restart the app and repeat the steps 2, 3 and 4 there is no the glitch anymore and I have the following in logs:

09-04 21:36:34.332 20449 20449 D InterstitialAdWrapper: In the onCreate() event
09-04 21:36:34.339 20449 20449 D InterstitialAdWrapper: Initializing the Mobile Ads SDK...
09-04 21:36:34.465 20449 20449 D InterstitialAdWrapper: Creating InterstitialAd...
09-04 21:36:34.467 20449 20449 D InterstitialAdWrapper: Loading on UI thread...
09-04 21:36:34.468 20449 20449 D InterstitialAdWrapper: Loading InterstitialAd...
09-04 21:36:34.529  1056 20605 I chatty  : uid=1041(audioserver) Binder:1056_A expire 34 lines
09-04 21:36:34.532 20449 20449 D InterstitialAdWrapper: In the onStart() event
09-04 21:36:34.536 20449 20449 D InterstitialAdWrapper: In the onResume() event
09-04 21:36:34.537 20449 20467 E FA      : Scheduler not set. Not logging error/warn
09-04 21:36:34.543 20449 20467 I FA      :   adb shell setprop debug.firebase.analytics.app net.geographx.LinesGame
09-04 21:36:34.746  2089  2283 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{ecf787c u0 net.geographx.LinesGame/net.geographx.MainActivity t555} time:24675171
09-04 21:36:34.753  2089  2276 I chatty  : uid=1000(system) ActivityManager expire 6 lines
09-04 21:36:34.755  2089  2276 W System.err: java.io.FileNotFoundException: /acct/uid_1000/pid_5797/cgroup.procs (No such file or directory)
09-04 21:36:34.764 20449 20465 D libLinesGameQt.so: Translation file has been loaded successfully:  "LinesGame_ru"
09-04 21:36:34.765 20449 20465 D Линии: App version:  "2.5.0, #74"
09-04 21:36:34.771 20449 20465 D Линии: QT/SysInfo: Device Pixel Ratio: 2.99861  Screen DPI:  134.686
09-04 21:36:34.775 20449 20513 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/qml/QtQuick.2/libqtquick2plugin.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.783 20449 20513 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.806 20449 20513 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/qml/QtQuick/Layouts/libqquicklayoutsplugin.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.812 20449 20513 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/qml/QtQuick/Dialogs/libdialogplugin.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.820 20449 20513 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/qml/QtQuick/Templates.2/libqtquicktemplates2plugin.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.841 20449 20513 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/qml/QtQuick/Window.2/libwindowplugin.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.861 20449 20465 D Линии: InterstitialAdWrapper  valid
09-04 21:36:34.866   721   721 I chatty  : uid=1041(audioserver) audio@2.0-servi expire 6 lines
09-04 21:36:34.880  1056 20605 I chatty  : uid=1041(audioserver) Binder:1056_A expire 3 lines
09-04 21:36:34.892 20449 20465 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqgif.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.893 20449 20465 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqicns.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.894 20449 20465 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqico.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.896 20449 20465 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqjpeg.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.897 20449 20465 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqsvg.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.898 20449 20465 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqtga.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.899 20449 20465 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqtiff.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.900 20449 20465 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqwbmp.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:34.901 20449 20465 W linker  : "/data/data/net.geographx.LinesGame/qt-reserved-files/plugins/imageformats/libqwebp.so" has unsupported flags DT_FLAGS_1=0x80
09-04 21:36:35.131 20449 20465 D Линии: qml: changeLogIndex: true
09-04 21:36:35.133   715   715 I chatty  : uid=1000(system) allocator@1.0-s expire 10 lines
09-04 21:36:35.135  1056  1284 I chatty  : uid=1041(audioserver) ApmOutput expire 8 lines
09-04 21:36:35.136 20449 20465 D Линии: Starting the application event loop...
09-04 21:36:35.136   721  3946 I chatty  : uid=1041(audioserver) writer expire 124 lines
09-04 21:36:35.197 20449 20465 D Линии: onApplicationStateChanged(Qt::ApplicationActive)
09-04 21:36:35.201   721  2374 I chatty  : uid=1041(audioserver) HwBinder:721_3 expire 8 lines
09-04 21:36:35.781 20449 20449 W ResourceType: Failure getting entry for 0x7f130532 (t=18 e=1330) (error -2147483647)
09-04 21:36:35.786  2089  3282 I ActivityManager: Start proc 20535:com.android.chrome:sandboxed_process0/u0i37 for webview_service net.geographx.LinesGame/org.chromium.content.app.SandboxedProcessService0 caller=net.geographx.LinesGame
09-04 21:36:35.878 20449 20449 W raphx.LinesGame: type=1400 audit(0.0:4944): avc: denied { read } for name="vmstat" dev="proc" ino=4026532118 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:proc:s0 tclass=file permissive=0
09-04 21:36:35.913 20535 20535 D         : Regionalization Environment load packages for Carrier error!
09-04 21:36:36.013 20535 20535 D ThemeCompatibility: getVersion(): /data/system/theme_config/theme_compatibility.xml  java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml (No such file or directory)
09-04 21:36:36.013 20535 20535 W System.err: java.io.FileNotFoundException: /data/system/theme_config/theme_compatibility.xml (No such file or directory)
09-04 21:36:36.067 20535 20535 W PackageManager: Failure retrieving text 0x7f0c001f in package net.geographx.LinesGame
09-04 21:36:36.067 20535 20535 W PackageManager: java.lang.NullPointerException: Attempt to invoke virtual method 'void miui.content.res.ThemeResourcesSystem.mergeThemeValues(java.lang.String, miui.content.res.ThemeValues)' on a null object reference
09-04 21:36:36.151  2089  6524 W System.err: java.io.FileNotFoundException: /acct/uid_99037/pid_20535/cgroup.procs (No such file or directory)
09-04 21:36:36.479  1056 19779 I chatty  : uid=1041(audioserver) Binder:1056_9 expire 7 lines
09-04 21:36:36.481   721   721 I chatty  : uid=1041(audioserver) audio@2.0-servi expire 10 lines
09-04 21:36:36.485 20449 20449 D InterstitialAdWrapper: onAdLoaded
09-04 21:36:36.485 20449 20449 D Линии: InterstitialAdWrapper Native Loaded.
09-04 21:36:38.258  1056  1056 I chatty  : uid=1041(audioserver) /system/bin/audioserver expire 7 lines
09-04 21:36:38.280  1056  1284 I chatty  : uid=1041(audioserver) ApmOutput expire 60 lines
09-04 21:36:44.687  1056 20605 I chatty  : uid=1041(audioserver) Binder:1056_A expire 13 lines
09-04 21:36:45.209   721  4791 I chatty  : uid=1041(audioserver) HwBinder:721_4 expire 2 lines
09-04 21:36:46.439  1056 24029 I chatty  : uid=1041(audioserver) Binder:1056_10 expire 6 lines
09-04 21:36:46.790   715   715 I chatty  : uid=1000(system) allocator@1.0-s expire 18 lines
09-04 21:36:48.881  1056  1284 I chatty  : uid=1041(audioserver) ApmOutput expire 15 lines
09-04 21:36:48.978  1056  1056 I chatty  : uid=1041(audioserver) /system/bin/audioserver expire 3 lines
09-04 21:36:49.013   721  2374 I chatty  : uid=1041(audioserver) HwBinder:721_3 expire 2 lines
09-04 21:36:49.340  1056 20605 I chatty  : uid=1041(audioserver) Binder:1056_A expire 3 lines
09-04 21:36:49.367  1056 19779 I chatty  : uid=1041(audioserver) Binder:1056_9 expire 4 lines
09-04 21:36:49.965  1056  1284 I chatty  : uid=1041(audioserver) ApmOutput expire 4 lines
09-04 21:36:52.602  1056 24029 I chatty  : uid=1041(audioserver) Binder:1056_10 identical 2 lines
09-04 21:36:57.081   715   715 I chatty  : uid=1000(system) allocator@1.0-s expire 21 lines
09-04 21:36:57.568  1056 19779 I chatty  : uid=1041(audioserver) Binder:1056_9 identical 2 lines
09-04 21:37:01.003  1042  1164 I chatty  : uid=1000(system) HwBinder:1042_1 identical 11 lines
09-04 21:37:05.531  1056 20605 I chatty  : uid=1041(audioserver) Binder:1056_A identical 2 lines
09-04 21:37:09.042  1056 24029 I chatty  : uid=1041(audioserver) Binder:1056_10 identical 2 lines
09-04 21:37:11.724  1056 20605 I chatty  : uid=1041(audioserver) Binder:1056_A identical 2 lines
09-04 21:37:19.860  1056 19779 I chatty  : uid=1041(audioserver) Binder:1056_9 identical 2 lines
09-04 21:37:30.137   721  3946 E ACDB-LOADER: Error: ACDB_CMD_GET_AFE_COMMON_TABLE_SIZE Returned = -19
09-04 21:37:30.137   721  3946 E ACDB-LOADER: Error: ACDB AFE returned = -19
09-04 21:38:31.232 20449 20465 D Линии: InterstitialAdWrapper  calling show from C++
09-04 21:38:31.236 20449 20465 D Линии: InterstitialAdWrapper  valid
09-04 21:38:31.236 20449 20465 D InterstitialAdWrapper: Calling 'Show' on UI thread...
09-04 21:38:31.262 20449 20449 D InterstitialAdWrapper: Showing...
09-04 21:38:31.278  2089  3282 I ActivityManager: START u0 {cmp=net.geographx.LinesGame/com.google.android.gms.ads.AdActivity (has extras)} from uid 10168
09-04 21:38:31.284  2089  3282 D ActivityTrigger: activityStartTrigger: Activity is Triggerred in full screen ApplicationInfo{a68a94f net.geographx.LinesGame}
09-04 21:38:31.284  2089  3282 E ActivityTrigger: activityStartTrigger: not whiteListednet.geographx.LinesGame/com.google.android.gms.ads.AdActivity/74
09-04 21:38:31.285  2089  3282 D ActivityTrigger: activityResumeTrigger: The activity in ApplicationInfo{a68a94f net.geographx.LinesGame} is now in focus and seems to be in full-screen mode
09-04 21:38:31.285  2089  3282 E ActivityTrigger: activityResumeTrigger: not whiteListednet.geographx.LinesGame/com.google.android.gms.ads.AdActivity/74
09-04 21:38:31.290 20449 20449 D InterstitialAdWrapper: In the onPause() event
09-04 21:38:31.292  2089  3237 D ActivityTrigger: activityResumeTrigger: The activity in ApplicationInfo{a68a94f net.geographx.LinesGame} is now in focus and seems to be in full-screen mode
09-04 21:38:31.292  2089  3237 E ActivityTrigger: activityResumeTrigger: not whiteListednet.geographx.LinesGame/com.google.android.gms.ads.AdActivity/74
09-04 21:38:31.297  3268  3446 I WtProcessController: MOVE TO FOREGROUND: net.geographx.LinesGame 10168
09-04 21:38:31.298  3268  3446 I WtProcessController: FOREGROUND INFO: name=net.geographx.LinesGame uid=10168 pid=20449 TaskId:555
09-04 21:38:31.314 20449 20449 D InterstitialAdWrapper: onAdOpened
09-04 21:38:31.314 20449 20449 D Линии: InterstitialAdWrapper Native Opened.
09-04 21:38:31.317 20449 20465 D Линии: onApplicationStateChanged(Qt::ApplicationInactive)
09-04 21:38:31.433  2089  2283 I ActivityManager: Displayed net.geographx.LinesGame/com.google.android.gms.ads.AdActivity: +136ms
09-04 21:38:31.435  2089  2283 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{49d09e8 u0 net.geographx.LinesGame/com.google.android.gms.ads.AdActivity t555} time:24791860
09-04 21:38:40.457  2089  2332 W System.err: java.io.FileNotFoundException: /acct/uid_10018/pid_3316/cgroup.procs (No such file or directory)
09-04 21:38:40.461  2089  2332 W System.err: java.io.FileNotFoundException: /acct/uid_10168/pid_20449/cgroup.procs (No such file or directory)
09-04 21:38:40.463  2089  2332 W System.err: java.io.FileNotFoundException: /acct/uid_99037/pid_20535/cgroup.procs (No such file or directory)
09-04 21:38:40.465  2089  2332 W System.err: java.io.FileNotFoundException: /acct/uid_1000/pid_5797/cgroup.procs (No such file or directory)
09-04 21:38:40.930  2089  2276 W System.err: java.io.FileNotFoundException: /acct/uid_10168/pid_20449/cgroup.procs (No such file or directory)
09-04 21:38:40.931 20449 20449 D InterstitialAdWrapper: In the onStop() event
09-04 21:38:40.933   760   832 E BufferQueueProducer: [SurfaceView - net.geographx.LinesGame/net.geographx.MainActivity#0] disconnect: not connected (req=1)
09-04 21:38:40.933 20449 20465 D Линии: onApplicationStateChanged(Qt::ApplicationSuspended)
09-04 21:38:40.939  2089  2276 W System.err: java.io.FileNotFoundException: /acct/uid_99037/pid_20535/cgroup.procs (No such file or directory)
09-04 21:38:42.532  2089  6524 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=net.geographx.LinesGame/net.geographx.MainActivity bnds=[74,1610][242,1778] (has extras)} from uid 10018
09-04 21:38:42.547  2089  6524 D ActivityTrigger: activityResumeTrigger: The activity in ApplicationInfo{a68a94f net.geographx.LinesGame} is now in focus and seems to be in full-screen mode
09-04 21:38:42.547  2089  6524 E ActivityTrigger: activityResumeTrigger: not whiteListednet.geographx.LinesGame/com.google.android.gms.ads.AdActivity/74
09-04 21:38:42.552  2089  6524 D ActivityTrigger: activityResumeTrigger: The activity in ApplicationInfo{a68a94f net.geographx.LinesGame} is now in focus and seems to be in full-screen mode
09-04 21:38:42.552  2089  6524 E ActivityTrigger: activityResumeTrigger: not whiteListednet.geographx.LinesGame/com.google.android.gms.ads.AdActivity/74
09-04 21:38:42.559  2089  3282 D ActivityTrigger: activityResumeTrigger: The activity in ApplicationInfo{a68a94f net.geographx.LinesGame} is now in focus and seems to be in full-screen mode
09-04 21:38:42.559  2089  3282 E ActivityTrigger: activityResumeTrigger: not whiteListednet.geographx.LinesGame/com.google.android.gms.ads.AdActivity/74
09-04 21:38:42.563  2089  3282 W System.err: java.io.FileNotFoundException: /acct/uid_10168/pid_20449/cgroup.procs (No such file or directory)
09-04 21:38:42.565  2089  3282 W System.err: java.io.FileNotFoundException: /acct/uid_10018/pid_3316/cgroup.procs (No such file or directory)
09-04 21:38:42.567  2089  3282 W System.err: java.io.FileNotFoundException: /acct/uid_99037/pid_20535/cgroup.procs (No such file or directory)
09-04 21:38:42.569  3268  3446 I WtProcessController: MOVE TO FOREGROUND: net.geographx.LinesGame 10168
09-04 21:38:42.569  3268  3446 I WtProcessController: FOREGROUND INFO: name=net.geographx.LinesGame uid=10168 pid=20449 TaskId:555
09-04 21:38:42.572 20449 20449 D InterstitialAdWrapper: In the onRestart() event
09-04 21:38:42.580 20449 20449 D InterstitialAdWrapper: In the onStart() event
09-04 21:38:42.999  2089  2283 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{49d09e8 u0 net.geographx.LinesGame/com.google.android.gms.ads.AdActivity t555} time:24803424
09-04 21:38:42.999  2089  2283 I Timeline: Timeline: Activity_windows_visible id: ActivityRecord{ecf787c u0 net.geographx.LinesGame/net.geographx.MainActivity t555} time:24803424
09-04 21:38:43.016  2089  2276 W System.err: java.io.FileNotFoundException: /acct/uid_10018/pid_3316/cgroup.procs (No such file or directory)
09-04 21:38:43.022  2089  2276 W System.err: java.io.FileNotFoundException: /acct/uid_1000/pid_5797/cgroup.procs (No such file or directory)
09-04 21:39:00.532   776   787 I chatty  : uid=0(root) /vendor/bin/mmid identical 4 lines
09-04 21:39:03.568  1042  1164 I chatty  : uid=1000(system) HwBinder:1042_1 identical 13 lines

the only notable difference is that the app is activated (or resumed) with onRestart but not with onCreate. I can’t reproduce this if I install the app via USB with ADB or if I install the app on an emulator or 32-bit phone.

After investigating what Android Activity launchMode is, I realized that it was not a disappointing glitch, but a normal Android behavior. When I changed launchMode in the application manifest from singleTop to singleTask, the main activity’s onCreate handler stopped being called when I reactivate the app by clicking on its icon:

adb logcat | egrep -i InterstitialAdWrapper
09-13 18:43:34.254 32354 32354 D InterstitialAdWrapper: In the onCreate() event
09-13 18:43:34.256 32354 32354 D InterstitialAdWrapper: Initializing the Mobile Ads SDK...
09-13 18:43:35.046 32354 32354 D InterstitialAdWrapper: Creating InterstitialAd...
09-13 18:43:35.046 32354 32354 D InterstitialAdWrapper: Loading on UI thread...
09-13 18:43:35.047 32354 32354 D InterstitialAdWrapper: Loading InterstitialAd...
09-13 18:43:35.173 32354 32354 D InterstitialAdWrapper: In the onStart() event
09-13 18:43:35.183 32354 32354 D InterstitialAdWrapper: In the onResume() event
09-13 18:43:35.897 32354 32426 D Линии: InterstitialAdWrapper  valid
09-13 18:43:37.818 32354 32354 D InterstitialAdWrapper: onAdLoaded
09-13 18:43:37.818 32354 32354 D Линии: InterstitialAdWrapper Native Loaded.
09-13 18:44:29.201 32354 32426 D Линии: InterstitialAdWrapper  calling show from C++
09-13 18:44:29.201 32354 32426 D Линии: InterstitialAdWrapper  valid
09-13 18:44:29.201 32354 32426 D InterstitialAdWrapper: Calling 'Show' on UI thread...
09-13 18:44:29.229 32354 32354 D InterstitialAdWrapper: Showing...
09-13 18:44:29.260 32354 32354 D InterstitialAdWrapper: In the onPause() event
09-13 18:44:29.281 32354 32354 D InterstitialAdWrapper: onAdOpened
09-13 18:44:29.281 32354 32354 D Линии: InterstitialAdWrapper Native Opened.
09-13 18:44:37.260 32354 32354 D InterstitialAdWrapper: In the onStop() event
09-13 18:44:39.114 32354 32354 D InterstitialAdWrapper: onAdClosed
09-13 18:44:39.114 32354 32354 D Линии: InterstitialAdWrapper Native AdClosed.
09-13 18:44:39.114 32354 32354 D InterstitialAdWrapper: Loading on UI thread...
09-13 18:44:39.114 32354 32354 D InterstitialAdWrapper: Loading InterstitialAd...
09-13 18:44:39.145 32354 32354 D InterstitialAdWrapper: In the onRestart() event
09-13 18:44:39.147 32354 32354 D InterstitialAdWrapper: In the onStart() event
09-13 18:44:39.148 32354 32354 D InterstitialAdWrapper: In the onResume() event
09-13 18:44:41.331 32354 32354 D InterstitialAdWrapper: onAdLoaded
09-13 18:44:41.331 32354 32354 D Линии: InterstitialAdWrapper Native Loaded.

Leave a Reply

Your email address will not be published.