← All issues

AudioVideoRenderer SharedTimebase ownership and drift reduction

d2af128

WebKit에서 미디어 재생은 process 경계를 넘나드는 구조로 동작합니다. GPU process에서는 AVSampleBufferRenderSynchronizer가 실행되며, 그 CMTimebase가 기준 시각 역할을 합니다. 한편 WebContent process는 스크립트 실행 중이나 requestAnimationFrame 콜백에서 currentTime을 읽어옵니다. 이 두 process를 연결하는 것이 SharedTimebase로, lock-free SequenceLocked 공유 메모리 영역을 통해 데이터를 교환합니다. GPU process는 currentTime, hostTime, rate로 구성된 snapshot을 기록하고, reader 측은 이를 바탕으로 현재 시각을 외삽합니다.

Source/WebCore/platform/SharedTimebase.cpp

- auto elapsed = std::min(m_clock() - snapshot.hostTime, m_maxExtrapolation);
- calculated = snapshot.currentTime + MediaTime::createWithDouble(rate * elapsed.seconds());
+ auto elapsed = m_clock() - snapshot.hostTime;
+ calculated = (snapshot.currentTime + MediaTime::createWithDouble(rate * elapsed.seconds())).toTimeScale(snapshot.currentTime.timeScale());

이번 commit에서는 SharedTimebase의 소유권이 RemoteAudioVideoRendererProxyManager에서 AudioVideoRendererAVFObjC로 이전되었습니다. 아울러 snapshot을 게시하는 세 가지 경로가 추가되었습니다. 첫째는 main thread에서의 상태 변경, 둘째는 전용 serial queue 위에서 동작하는 100ms 주기의 dispatch timer, 셋째는 AVF thread에서 호출되는 동기 rate→0 callback입니다. 세 경로 모두 publishSnapshot() helper를 통해 수렴되며, 공유 메모리에 기록하기 전 high-water-mark 방식의 하한 클램프를 적용합니다. 기존의 maxExtrapolation 상한은 제거되었고, 그 역할을 m_publishedTimeFloor(writer 측, seek 시에만 초기화)와 m_lastReturnedTime(reader 측, 단조 증가 보장)이 대신합니다.

이번 변경은 미디어 currentTime이 GPU/WebContent process 경계를 넘어 계산되고 공유되는 방식을 직접 수정합니다. cross-process 공유 메모리 의미론, lock 규율, 그리고 timing 기반 API에서 보안과 직결되는 forward-monotonicity 불변성 전반에 영향을 미칩니다.

🔒

The instrumentation's custom memory lifecycle and protection-state management introduce several audit-worthy edge cases in the guarded path.

더 확인하려면 구독해 주세요