Skip to content

Commit

Permalink
[visionOS] Safari YouTube audio location stays stationary when window…
Browse files Browse the repository at this point in the history
… is moved while viewing other tab (audio is not spatial)

https://bugs.webkit.org/show_bug.cgi?id=260364
<radar://112181086>

Reviewed by Andy Estes.

Set the STSLabel when the viewer becomes invisible so audio follows the scene.

Set it back to nil when the viewer becomes visible to restore the current behavior.

* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setPageIsVisible):

* Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h:
Stage SPI for non-internal clients.

Canonical link: https://commits.webkit.org/267018@main
  • Loading branch information
mwyrzykowski committed Aug 17, 2023
1 parent a2c3c28 commit 4c5bf81
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Source/WebCore/PAL/pal/spi/cocoa/AVFoundationSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,10 @@ NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_END
#endif

#if __has_include(<AVFoundation/AVSampleBufferVideoRenderer_Private.h>)
#import <AVFoundation/AVSampleBufferVideoRenderer_Private.h>
#elif PLATFORM(VISION)
@interface AVSampleBufferVideoRenderer (AVSampleBufferVideoRendererWebKitPrivate)
@property (nonatomic, copy, nullable, getter=_STSLabel) NSString *STSLabel SPI_AVAILABLE(ios(15.0)) API_UNAVAILABLE(macos, tvos, watchos);
@end
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,14 @@ void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types) const f
m_visible = visible;
if (m_visible)
acceleratedRenderingStateChanged();

#if PLATFORM(VISION)
if (!visible) {
AVAudioSession *session = [PAL::getAVAudioSessionClass() sharedInstance];
[m_sampleBufferDisplayLayer sampleBufferRenderer].STSLabel = session.spatialTrackingLabel;
} else
[m_sampleBufferDisplayLayer sampleBufferRenderer].STSLabel = nil;
#endif
}

MediaTime MediaPlayerPrivateMediaSourceAVFObjC::durationMediaTime() const
Expand Down

0 comments on commit 4c5bf81

Please sign in to comment.