google / oboe

Oboe is a C++ library that makes it easy to build high-performance audio apps on Android.
Apache License 2.0
3.69k stars 564 forks source link

ErrorInternal when trying to open a stream #1492

Open GayleDaVid opened 2 years ago

GayleDaVid commented 2 years ago

Android version(s):12,11,10,9,8.1.0 Android device(s): Samsung Galaxy A Variants, Vivo 1807, Vivo 1811, vivo 1904, vivo 1906, vivo 2007, CPH2239, CPH2161, V2048, V2026, Redmi Note 9, Redmi 9A, Redmi 9, POCO X3 Pro, Realme C21-Y, realme Narzo 20, RMX3231, realme 6, realme 7, ANE-LX1, OnePlus Nord2 5G, vivo 1718,... Oboe version: 1.6.1 App name used for testing: Smule

Short description When opening a stream you are presented with the ErrorCode ErrorInternal

Steps to reproduce Select 'Sing' on any song from the Songbook, Select any method; Solo, Group, Duet, Join Error code shown

Expected behavior no error code

Actual behavior error code

Any additional context Point to note, that the record permission is in the manifest and the permission is requested from the user.

    stream_builder.setDirection(stream_direction);  //Direction::Output || Direction::Input
    stream_builder.setSampleRate(sample_Rate); // 48000
    stream_builder.setFramesPerDataCallback(buffer_size); //240 , 192, 1024, 256
    stream_builder.setSampleRateConversionQuality(oboe::SampleRateConversionQuality::Medium);
    stream_builder.setFormat(/AudioFormat::I16); 
    stream_builder.setSharingMode(oboe::SharingMode::Exclusive);
    stream_builder.setPerformanceMode(PerformanceMode::LowLatency);

The value we set for the setFramesPerDataCallback and setSampleRate are obtained from AudioManager. We were not able to reproduce this in house, however clients report experiencing it

philburk commented 2 years ago

It looks like what you are doing is fine. And the failure happens rarely. I suspect it may be related to device specific failures, maybe at the hardware level.

There is not much we can do without a bugreport. If you can reproduce it, or get a bugreport from the field then we would be very happy to review it.

GayleDaVid commented 2 years ago

Hey Phil I was able to obtain a bugreport. I have attached them to the issue tracker which can be found here https://issuetracker.google.com/issues/227624430

philburk commented 2 years ago

The bugreport that you sent said the phone had been running for 42 days. Many activities were being killed around the same time. Internally we reboot several times per day when developing Android. I suspect that fragmentation, resource leaks, and other issues may have built up. We will continue to investigate this.

What devices crash most often? Any statistics you can share may be helpful.

GayleDaVid commented 2 years ago

Hello Phil thanks for continuing to look into this. The device which we obtained the bugreport from was from our internal testing as we were unable to get any data from clients.

What devices crash most often? Any statistics you can share may be helpful.

So far we have seen 70% of devices on Android 11, 17% Android 8.1.0, 10% Android 10, 4% Android 9 48% on Vivo devices Vivo 1807, vivo 1811, vivo 1906, vivo 1904, v2026, V2068, V2033, V2037, vivo 1718, V2043, vivo 2015, V2102, vivo 2007 30% Samsung, Galaxy A12, Galaxy A10, Galaxy A22 5G, Galaxy M11, Galaxy A02s, Galaxy 10s, Galaxy A03s, Galaxy A20, Galaxy A03 Core, Galaxy A32 5G 11% Realme - RMX3231, realme C12, C21-Y, Narzo 50A, Narzo 20, 6 ,7, 8 5g, C21, C15, Narzo 30 9% Xiaomi - Redmi Note 9, Redmi 9, Redmi 9A, Redmi Note 8, POCO X3 Pro, Redmi 10 2022, Redmi Note 10 Pro, Mi A2 Lite

We will continue to try to reproduce in house to give more details/bugreports whenever we are able to experience it again.

philburk commented 2 years ago

So far we have seen 70% of devices on Android 11, 17% Android 8.1.0, 10% Android 10, 4% Android 9

So you are not seeing any failures on Android 12. So this issue may have been fixed in 12. Or the number may be too low to measure.

GayleDaVid commented 2 years ago

So you are not seeing any failures on Android 12. So this issue may have been fixed in 12. Or the number may be too low to measure.

From the previous report, it seemed like the value was too small to measure. Today I am able to see Android 12 in the report as well, I believe this is as more users are starting to adopt the Android 12 OS. As on today the stats are;

philburk commented 2 years ago

This is unrelated to the ErrorInternal, but...

The value we set for the setFramesPerDataCallback and setSampleRate are obtained from AudioManager.

Note that you should only setFramesPerDataCallback if you need a particular callback size or a fixed callback size. AAudio will choose its own optimal buffer size. For Legacy code the callback size may vary when there is sample rate conversion.