-
Notifications
You must be signed in to change notification settings - Fork 572
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
Pure virtual function called! #2029
Comments
@flornil - I checked all of the destructors in Oboe. I only found empty or default destructors. /lib/arm64/libasdjni.so (__cxa_pure_virtual+16) (BuildId: c79d458d9cccb9a572422d454aad9c5c6de60987) It looks like the pure virtual is in "libasdjni". What is that? |
"libasdjni" is myJNI library containing among other things the audio output code. I also don't do any virtual function calls from any destructor. |
@flornil - Are you by any chance using the sample rate converter in Oboe to get a sample rate other than 48000 Hz? We have just found that can cause a race condition when disconnecting a stream if the app is also closing the stream. AudioStreamCallback looks OK. |
My app is a file player and it uses the file sample rate: After I changed my audio output class from subclassing oboe::AudioStreamCallback into how you do in the "SimpleNoiseMaker" sample, the crashes as reported in the developer console have now also changed. First crash: backtrace: another crash I've never seen before backtrace: and the last crash: Thread backtrace: |
@philburk - Here is picture with some log messages from Android Studio: |
Are you receiving broadcast intents when a headset is plugged in and then closing the stream from your app? |
The warnings doesn't seem to cause any problems or crashes. I will release yet another version using oboe 1.9.0 to see if that changes anything. |
I have released several versions of my app and testing different solutions:
I've tried using oboe as a static lib or as shared lib, no difference. I'm building my oboe libs on a Mac with android-ndk-r21e The crashes are not frequent but there should be zero crashes. So either the problem is how I build oboe or how I integrate it into my app or maybe maybe it's some problem inside oboe? I'm stuck. Below are som sample crash reports that might tell you something? ///////////////////////// Thread backtrace: ///////////////////////// #00 pc 0x0000000000019b3c /data/app/~~Lc1LboJ6mxBc9Fk4mCow8Q==/com.ronimusic.asd-YGne_fUhvlUxoiuFfQtiYg==/lib/arm/liboboe.so (BuildId: 53899adb8149187c68f175fdd41b6e2c04e024bc) ///////////////////////// |
I totally agree. The goal is ZERO crashes. So I appreciate your reports. Thank you. This part of the stack trace is very interesting. ::deallocate(void*, scudo::Chunk::Origin, unsigned long, unsigned long)+316) (oboe::AudioStreamAAudio::internalErrorCallback(AAudioStreamStruct*, void*, int)+176) (BuildId: 5b9fa849aa907405fcb9f1c36ef530e0ffc68401) So a deallocate is happening in AudioStreamAAudio::internalErrorCallback(). @flornil - Are you using Oboe 1.9.0 yet? It fixed a problem involving sample rate conversion and shared pointers. It affected internalErrorCallback(). See #2035 |
@philburk - I'm actually using oboe 1.9.1 downloaded last week but the crash in internalErrorCallback() might be using oboe 1.9.0, or even oboe 1.8.1, not sure. The most common crash looks like this: backtrace: ///////////////// My guess is that the audioData pointer in onAudioReady(oboe::AudioStream*, void* audioData, int numFrames) is also deallocated when my app is trying to write data into it, the pointer is not NULL and I'm not writing more (and not less) than numFrames of data into it. And I don't know when this crash happens, maybe when a user changes audio output, headphones, Bluetooth etc. |
I think I understand the problem. I've based my oboe audio class on the SimpleNoiseMaker sample. This class has two private classes: The error callback has a pointer to the parent class (which is the audio output class). mErrorCallback = std::make_shared(this); oboe has its own shared_ptr to the MyErrorCallback class void SimpleNoiseMaker::MyErrorCallback::onErrorAfterClose(...) I did the same for my oboe::AudioStreamDataCallback meaning keeping a pointer to the parent class, I have now reverted back to my old code that subclasses the oboe::AudioStreamCallback. This has worked fine except for the "Pure virtual function called!" crash that started all this, oh well... I will release another update and keep you informed. |
@flornil wrote:
I don't think that will compile. Did you mean:
The audio class should NOT get destroyed. Note that the SimpleNoiseMaker object was statically declared
Do you stop the audio when your Activity stops or is destroyed? Here is the code in the MinimalOboe example that stops and closes the audio stream when the Audio Activity finishes.
|
OK, that explains the crashes. I assumed it was possible to create and destroy the audio class as any other class, I do that on Mac, Windows and iOS since many years without any problem. It works with my OpenSLES class on Android as well but oboe is designed in another way. Assumptions are seldom a good thing but now I know for sure how to do it. From now my oboe class will be statically declared. |
OK, I will close this. Feel free to open another bug if you hit another crash. |
Oboe version 1.8.1 any Android version
On my developer console I see the following crash log:
Pure virtual function called!
backtrace:
#00 pc 0x00000000000940a4 /apex/com.android.runtime/lib64/bionic/libc.so (abort+164)
#1 pc 0x0000000000398d9c /data/app/~~i1cvwbdg2HgTVEVakOv5QQ==/com.mycompany.dsa-poBEPduzE4OcrN7uZHceDA==/lib/arm64/libasdjni.so (BuildId: c79d458d9cccb9a572422d454aad9c5c6de60987)
#2 pc 0x0000000000396b0c /data/app/~~i1cvwbdg2HgTVEVakOv5QQ==/com.mycompany.dsa-poBEPduzE4OcrN7uZHceDA==/lib/arm64/libasdjni.so (__cxa_pure_virtual+16) (BuildId: c79d458d9cccb9a572422d454aad9c5c6de60987)
#3 pc 0x0000000000345c2c /data/app/~~i1cvwbdg2HgTVEVakOv5QQ==/com.mycompany.dsa-poBEPduzE4OcrN7uZHceDA==/lib/arm64/libasdjni.so (BuildId: c79d458d9cccb9a572422d454aad9c5c6de60987)
#4 pc 0x0000000000347b18 /data/app/~~i1cvwbdg2HgTVEVakOv5QQ==/com.mycompany.dsa-poBEPduzE4OcrN7uZHceDA==/lib/arm64/libasdjni.so (void* std::__ndk1::__thread_proxy<std::__ndk1::tuple<std::__ndk1::unique_ptr<std::__ndk1::__thread_struct, std::__ndk1::default_deletestd::__ndk1::__thread_struct >, void ()(oboe::AudioStreamAAudio, oboe::Result), oboe::AudioStreamAAudio*, oboe::Result> >(void*)+48) (BuildId: c79d458d9cccb9a572422d454aad9c5c6de60987)
#5 pc 0x0000000000101c2c /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+204)
#6 pc 0x0000000000095a00 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64)
I've never seen the crash myself and it's very few crash reports.
"Pure virtual function called" may happen when one call a virtual subclass function in the base class destructor, I'm not doing that so my guess is that's a bug in the oboe library
The text was updated successfully, but these errors were encountered: