New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qt app unable to exit properly when using OneSignal Android SDK #102
Comments
After more researching, the problem is actually a little different. It is not regression of v3 (same problem with older versions), and crash is not actually on startup, but when last app instances is closing. So to describe more precisely:
Here's log starting when app is swiped-away:
So it might be problem with finalization when using within Qt app (with QtActivity/QtApplication?). |
Some more details: if I launch app from Android and close it immediately, and then open it again within around 20 seconds after app was closed, that new app instance freezes with message:
After that second instances it's killed, I can launch app successfully. |
I've testes official OneSignal example from 3.1.0 tarball, and it works OK. I can open and close and open example app without problem. But in my case with Qt app, closing it makes it freeze for ~20 seconds. |
Here's some interesting logcat output when I close app within Android (it actually dies after ~20s):
Full log:
|
@Talkless Thanks for the details and digging into the issue. You only started seeing this issue after updating from 2.3.0 of our SDK to 3.1.0? Can you pull the ANR log for your device? |
@jkasten2 Looks like it's the same with 2.x. I believe that earlier, when I was playing with 2.3, I was closing app directly from debugger, simply killing it, without noticing this freezing issue. ANR: Iteresting part:
Looks like as Qt actually tries to quit, but it waits for something. Using OneSignal library prevents it to exit somehow. Maybe I should produce minimal example app and post into Qt bug tracker..? |
I've created Qt bug report with attached working example source (without valid app IDs though). |
@jkasten2 I've found interesting comment in SyncService, which describes my problem exactly:
Looks like it does not work in Qt app for some reason? |
Looks like workaround is to set |
@Talkless The line number does match up exactly to your stack but the issue seems to be point to this method.
|
Looks like it's native method defined in androidjnimain.cpp.
I'll try that.
Yeah, it kinda looks like it.
Thanks for your work! |
* android:stopWithTask is affecting the QT framework in an unexpected way which locks the process when closing it. - See QTBUG-55846 and OneSignal issue #102 for more details on the specific issue. * Tested the flag removal on Android 4.4.2 and 6.0.1 and it had no side affects on onTaskRemoved.
@Talkless Wasn't able to find any detailed information on I have removed the flag in commit 07ba32f from the SDK's Feel free to reopen the issue if you see future issues with the service and Qt. |
Sorry, I do not follow. So But my workaround was |
@Talkless Sorry you're right, though you stated that the removal of the flag also worked and didn't reread your Sept 8th comment before making that commit. This seems to be a bug related to Qt handling services but I'll reopening the issue so this conflict can be tracked. You might have better luck from Qt's end if you can reproduce the issue with a simple project without OneSignal so they have less to review. We just simply start the service like the following in the OneSignal SDK code. startService(new Intent(context, ExampleService.class)); |
OK thanks, I'll inform about progress, if any. |
I've had the same issue as the one described here (with an identical ANR). Explicitly setting
in my AndroidManifest.xml did resolve the issue on my Samsung Galaxy S6 (Android 6.0.1), but did not resolve it on my Nexus 6 (Android 7.0.1). |
@jkasten2 - Thanks! Testing it right now. |
@jkasten2 - Unfortunately it didn't work :( |
That was without:
|
Hi @Talkless, I'm experiencing the same issue, did you open a Qt bug as follow up for that one or is there a workaround you're using for now? Thanks |
@alexleutgoeb There is bug report. I haven't tried latest OneSignal SDK yet, my walkaround was this. |
@Talkless I see, did you experience any side effects so far? |
@alexleutgoeb I have not experienced any specific side effects, it basically worked, but, that Qt project is on hold and there are not much actual experience. |
I'm experiencing the same issue too. @alexleutgoeb did you solved this problem in v-play? |
Hi @HamedMasafi, yes we applied the mentioned workaround and it is working so far! |
@Talkless Looping back around to this issue in my investigation of our ANR issues. I was able to reproduce this ANR without OneSignal with your example project with just a blank Android Service. Left a comment on the Qt issue with more details below; If you find any Qt documentation on limitations of Android Services please link them here and we can take a look. We are also currently looking into other ANRs so our future changes may end up fixing this one, depending on what we change. I'll leave this issue open until then |
We made some large changes to the SyncService which I believe should fix this issue in PR #470. This will released it this week under the version 3.8.2 which you can watch for on our Releases Page @Talkless Feel free to follow up here about the Qt ticket even if this OneSignal update fixes your issue. Interested to know the root of the Qt issue as it may help us prevent an ANR like this with Qt or otherwise. |
Amazing! Thanks! So we will be able to remove that |
Since persisting is done with Not sure if you are still using our .jar directly in your Qt project but we recommend adding our SDK through gradle with the following. dependencies {
compile 'com.onesignal:OneSignal:[3.8.2, 3.99.99]'
} This way you won't have to maintain any future |
Hi,
First of all, of course, this is non standard usage of this library, but please bear with me.
I was experimenting with OneSignal 2.3 - 3.1 APIs on Android (and iOS) with Qt C++ application.
With Qt and C++, it works like this:
int main()
code runs from other thread.Everything was working quite OK, but after upgrading to latest v3.1.0 program started to crash randomly (somewhere >50% of the time!) when starting, somewhere during startInit()-->init().Program crashes when started after last instance was closed from android. Same for 2.x up to 3.1 versions. All I get is some random assembly output in QtCreator debugger page, and this Android log line:Crash occurres when trying to setup OneSignal in wrapper Java method like this:
From Qt side, it's called through JNI like this (though I doubt it is relevant, but maybe useful for someone):
Crash happens after some seconds of being frozen.
Interestingly, I have tried to pass m_activity.getApplication() to starInit() instead of activity, and then it did not crash, notifications worked, BUT, inFocusDisplaying() options was totally ignored (always used Notification type).
Now the question is, is this line in documentation actually crucial:
In OneSignal 2.3 there was .init() method witch worked without this restriction.Maybe problem is that I cannot initialize OneSignal in proper place using Qt?Problem with that is that Application class is implemented by Qt, as mentioned before, and Qt app creator has no control what happens during initialization, no way to implement onCreate(), unless one wishes to modify (and then merge) Qt code per-app basis...
So in retrospect, could that crash be because init() is called not within onCreate()? If yes, could it be workarounded, or maybe even fixed, somehow?
Thanks!
Update: Looks like issue is that Qt app cannot exit properly if OneSignal is initialzied, so launching another instance make's it crash (Android waits until last insntaces exist, but eventually it's killed, see later posts).
The text was updated successfully, but these errors were encountered: