Using the proximity sensor causes the system volume HUD to stop appearing

Hi!


I've detected an issue that I'm not sure if I'm doing something wrong or if it's a bug in iOS.

When I am playing a sound and activate the device's proximity sensor the system's volume indicator is no longer displayed on screen when using the volume keys.


I've created a simple app that loops a small mp3 and at the same time activates the proximity sensor.

Before I cover the sensor for the first time if I press the volume keys I see the system volume indicator as expected.

If I then cover the sensor and uncover it again and try to use the volume keys they work (i.e. the sound volume increases or decreases) but no visual indication is given.

Stopping the sound, killing and restaring the app don't fix the issue, most times I have to reboot the device in order for the volume indicator to appear on my app again.


This seems to be an issue with iOS, but I've checked other apps that don't exibith this behaviour, like WhatsApp, for example.


Do I need to configure something in the audio session to be able to use the proximity sensor?


Here is my sample code:


#import "ViewController.h"
#import <AVFoundation/AVFoundation.h>
@interface ViewController ()
@property (nonatomic, strong) AVAudioPlayer *audioPlayer;
@end
@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    if (!self.audioPlayer) {
        NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"sound" ofType:@"mp3"]];
        self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
        self.audioPlayer.numberOfLoops = -1;
    }
}
- (IBAction)btnPlayAction:(id)sender
{
    if (!self.audioPlayer.isPlaying) {
        [self.audioPlayer prepareToPlay];
        [self.audioPlayer play];
       
        [UIDevice currentDevice].proximityMonitoringEnabled = YES;
    }
}
- (IBAction)btnStopAction:(id)sender
{
    if (self.audioPlayer.isPlaying) {
        [self.audioPlayer stop];
       
        [UIDevice currentDevice].proximityMonitoringEnabled = NO;
    }
}
@end

We are seeing the same behavior in our application (a VOIP) app. Once the proximity sensor is engaged, the Volume HUD stops showing up.

After battling this for a while more, we decided to use a technical support slot and request help from Apple.

Here is their response:


"Thank you for contacting Apple Developer Technical Support (DTS). Our engineers have reviewed your request and have determined that this would be best handled as a bug report.

Please submit a complete bug report regarding this issue using the Bug Reporting tool"

Did you happen to log a radar? If so, what is the number?

22208709

Using the proximity sensor causes the system volume HUD to stop appearing
 
 
Q