← All reports

Decode VP8 in the content process in AudioVideoRendererRemote

Component: WebKit media | a4bfe4c

Source/WebKit/WebProcess/GPU/media/AudioVideoRendererRemote.cpp

bool AudioVideoRendererRemote::shouldDecodeInContentProcess(const TrackInfo& info, bool isProtected) const
{
- if (!m_audioDecodingInContentProcess || isProtected)
- return false;
+ if (isProtected)
+ return false;
...
+ if (info.isVideo())
+ return m_videoCodecsDecodedInContentProcess.contains(info.codecName());
+ if (!m_audioDecodingInContentProcess)
+ return false;
 
+AudioVideoRendererRemote::TrackState& AudioVideoRendererRemote::setTrackState(...)
+ if (isVideoTrack(trackIdentifier)) {
+ m_videoTrackState = state.moveToUniquePtr();
+ return *m_videoTrackState;
+ }
+ return m_audioTrackStates.set(trackIdentifier, WTF::move(state)).iterator->value.get();

AudioVideoRendererRemote는 GPU process에 있는 media renderer를 WebContent 쪽에서 대리하는 proxy입니다. 평소에는 압축된 sample을 IPC로 그대로 전달합니다. 다만 audio는 이전부터 WebContent에서 직접 decode할 수 있었고, 이 경우 PCM만 process 경계를 넘었습니다.

이번 commit에서는 VideoSoftwareDecodingInContentProcessEnabled 설정 뒤에 video 경로가 추가되었습니다. 이 설정은 기본값이 꺼져 있습니다. 활성화되면 새 preference인 MediaVideoCodecIDsDecodedInContentProcess에 나열된 video codec이 WebContent에서 decode됩니다. 기본값은 "vp08"이며, decode된 frame이 GPU process로 전송됩니다. 반면 protected video와 그 밖의 codec은 여전히 압축된 상태로 전달됩니다.

Track state 구조도 변경되었습니다. 기존 상태가 m_audioTrackStates와 단일 슬롯인 m_videoTrackState로 분리되었습니다. 이때 video track을 새로 추가하면 이전 track의 state가 해제됩니다.

테스트용 preference가 켜지면 신뢰할 수 없는 bitstream에 대한 software VP8 parsing이 GPU process에서 WebContent로 옮겨지고, media IPC payload도 압축된 sample에서 decode된 frame으로 바뀝니다.

Dispatcher thread에서 단일 슬롯 state를 교체하는 구조는 lifetime 버그를 찾아볼 만한 패턴입니다. 먼저 addTrack, flush, drain, failTrack이 처리 중인 decode callback과 race를 일으키지 않는지 점검할 필요가 있습니다. Destructor가 std::exchange로 state를 dispatcher에 넘기는 경로도 같은 관점에서 살펴봐야 합니다. 또한 교체된 track에 대해 processSample이 sample을 버리기 시작한 뒤에도, 이미 해제된 state보다 오래 살아남는 decoder callback이 있는지 확인해야 합니다.

라우팅 방식이 isVideoTrack/forEachTrackState로 바뀐 만큼, 기존의 단일 map을 여전히 전제하는 경로가 남아 있는지도 검토가 필요합니다. 한편 공격자가 고른 timestamp가 dispatchSample과 expectMinimumUpcomingPresentationTime으로 들어가므로, 처리 순서에 대한 점검도 의미가 있습니다.

수신 측도 살펴봐야 합니다. sendSample은 이전에 압축된 video를 전달했지만, 이제는 decode된 video를 전달합니다. 따라서 GPU process가 WebContent에서 새로 생성되는 frame의 속성을 무비판적으로 가정하지 않는지 확인해야 합니다. 마지막으로 WebProcess::updateProcessPreferences의 쉼표 구분 FourCC parsing에서 잘못된 항목이 어떻게 처리되는지, 그리고 runtime 중 preference가 변경되는 경우까지 점검하면 범위가 정리됩니다.