Author Topic: BASS Xamarin.Android on Xiaomi  (Read 260 times)

rafal.haly

  • Posts: 2
BASS Xamarin.Android on Xiaomi
« on: 23 Sep '22 - 11:50 »
Hi,
we are using Bass with Xamarin.Android and we have issue on Xiaomi phones with MIUI 12+.
During playback when app is background after some time like 20mins app is killed by the system with message.

Code: [Select]
08-16 17:05:52.867  2823  3590 W PowerChecker.Controller: autoKillApp, calling ProcessManager uid = 10255, pkg = my.package.name
08-16 17:05:52.867  1385  3217 I ProcessManager: Kill reason AutoPowerKill from pid=2823
08-16 17:05:52.873  1385  3217 I ProcessManager: AutoPowerKill: kill my.package.name Adj=200 State=4
08-16 17:05:52.873  1385  3217 I ActivityManager: Killing 22255:my.package.name/u0a255 (adj 200): AutoPowerKill

I've know Xiaomi is agressive on killing apps which are in background https://dontkillmyapp.com/, but I've tested several other app which are using ExoPlayer and none of them were killed by the system.
Then I've looked into our implementation and change a lot o stuff, just experimenting to see what will work and when I've change playback library from Bass to native Media Player https://developer.android.com/reference/android/media/MediaPlayer system stopped killing my app.
So my question is has anyone encounter similar issue. Maybe there is something wrong with our configuration.

Code: [Select]
var audioManager = (AudioManager)Application.Context.GetSystemService(Context.AudioService);
var sessionId = audioManager.GenerateAudioSessionId();
Bass.BASS_SetConfig(62, sessionId);
var bassInit = Bass.BASS_Init(-1, Frequency, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);

Ian @ un4seen

  • Administrator
  • Posts: 25268
Re: BASS Xamarin.Android on Xiaomi
« Reply #1 on: 23 Sep '22 - 15:18 »
Is your app only getting killed when nothing is playing or even when it is playing? If the former, does it still happen if you call BASS_Free? Please also confirm what output system you're using, ie. have you disabled AAudio via BASS_CONFIG_ANDROID_AAUDIO? In either case, you could try the opposite, to see if that makes any difference.

rafal.haly

  • Posts: 2
Re: BASS Xamarin.Android on Xiaomi
« Reply #2 on: 23 Sep '22 - 16:53 »
App is getting killed even during playing audio when app is in background. We are using foreground service to display information about what is playing as every other playing audio app.
We are using default setting for Bass_Config_Android_AAudio and according to documentation http://www.un4seen.com/doc/#bass/BASS_CONFIG_ANDROID_AAUDIO.html it's true so AAudio is on since devices are running is Android above 8.1 version. I've also checked setting AAudio to false but result is the same. Is there anything else I can check?

Ian @ un4seen

  • Administrator
  • Posts: 25268
Re: BASS Xamarin.Android on Xiaomi
« Reply #3 on: 23 Sep '22 - 18:01 »
Another thing you could try is including the BASS_DEVICE_SOFTWARE flag in your BASS_Init call to disable AAudio's low latency mode. And raising the BASS_CONFIG_DEV_PERIOD/BUFFER settings to reduce the update frequency.