Diff
Modified: trunk/Source/_javascript_Core/API/JSVirtualMachine.mm (277933 => 277934)
--- trunk/Source/_javascript_Core/API/JSVirtualMachine.mm 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/_javascript_Core/API/JSVirtualMachine.mm 2021-05-23 20:33:29 UTC (rev 277934)
@@ -38,12 +38,12 @@
#import "SigillCrashAnalyzer.h"
#import "SlotVisitorInlines.h"
#import <mutex>
-#import <wtf/Lock.h>
+#import <wtf/CheckedLock.h>
#import <wtf/RetainPtr.h>
static NSMapTable *globalWrapperCache = 0;
-static Lock wrapperCacheMutex;
+static CheckedLock wrapperCacheMutex;
static void initWrapperCache()
{
@@ -53,7 +53,7 @@
globalWrapperCache = [[NSMapTable alloc] initWithKeyOptions:keyOptions valueOptions:valueOptions capacity:0];
}
-static NSMapTable *wrapperCache()
+static NSMapTable *wrapperCache() WTF_REQUIRES_LOCK(wrapperCacheMutex)
{
if (!globalWrapperCache)
initWrapperCache();
Modified: trunk/Source/_javascript_Core/API/glib/JSCVirtualMachine.cpp (277933 => 277934)
--- trunk/Source/_javascript_Core/API/glib/JSCVirtualMachine.cpp 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/_javascript_Core/API/glib/JSCVirtualMachine.cpp 2021-05-23 20:33:29 UTC (rev 277934)
@@ -23,6 +23,7 @@
#include "JSCContextPrivate.h"
#include "JSCVirtualMachinePrivate.h"
#include "JSContextRef.h"
+#include <wtf/CheckedLock.h>
#include <wtf/HashMap.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/glib/WTFGType.h>
@@ -48,9 +49,9 @@
WEBKIT_DEFINE_TYPE(JSCVirtualMachine, jsc_virtual_machine, G_TYPE_OBJECT)
-static Lock wrapperCacheMutex;
+static CheckedLock wrapperCacheMutex;
-static HashMap<JSContextGroupRef, JSCVirtualMachine*>& wrapperMap()
+static HashMap<JSContextGroupRef, JSCVirtualMachine*>& wrapperMap() WTF_REQUIRES_LOCK(wrapperCacheMutex)
{
static LazyNeverDestroyed<HashMap<JSContextGroupRef, JSCVirtualMachine*>> shared;
static std::once_flag onceKey;
Modified: trunk/Source/_javascript_Core/ChangeLog (277933 => 277934)
--- trunk/Source/_javascript_Core/ChangeLog 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-05-23 20:33:29 UTC (rev 277934)
@@ -1,3 +1,31 @@
+2021-05-23 Chris Dumez <cdu...@apple.com>
+
+ Use CheckedLock in even more places
+ https://bugs.webkit.org/show_bug.cgi?id=226152
+
+ Reviewed by Darin Adler.
+
+ Use CheckedLock in even more places to benefit from Clang Thread Safety Analysis.
+
+ * API/JSVirtualMachine.mm:
+ (WTF_REQUIRES_LOCK):
+ * API/glib/JSCVirtualMachine.cpp:
+ * bytecode/StructureStubInfo.h:
+ * bytecode/SuperSampler.cpp:
+ * dfg/DFGCommonData.cpp:
+ (JSC::DFG::CommonData::invalidate):
+ (JSC::DFG::CommonData::~CommonData):
+ (JSC::DFG::CommonData::installVMTrapBreakpoints):
+ (JSC::DFG::codeBlockForVMTrapPC):
+ * dfg/DFGPlan.h:
+ (JSC::DFG::Plan::WTF_GUARDED_BY_LOCK):
+ * disassembler/Disassembler.cpp:
+ * heap/BlockDirectory.cpp:
+ (JSC::BlockDirectory::parallelNotEmptyBlockSource):
+ * heap/Heap.h:
+ * heap/IsoSubspacePerVM.h:
+ * inspector/remote/socket/RemoteInspectorConnectionClient.h:
+
2021-05-23 Ross Kirsling <ross.kirsl...@sony.com>
Unreviewed. Fix JSC Debug tests for r277926.
Modified: trunk/Source/_javascript_Core/bytecode/StructureStubInfo.h (277933 => 277934)
--- trunk/Source/_javascript_Core/bytecode/StructureStubInfo.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/_javascript_Core/bytecode/StructureStubInfo.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -38,6 +38,7 @@
#include "StructureStubClearingWatchpoint.h"
#include "StubInfoSummary.h"
#include <wtf/Box.h>
+#include <wtf/CheckedLock.h>
namespace JSC {
@@ -339,7 +340,7 @@
// Note that it's always safe to clear this. If we clear it prematurely, then if we see the same
// structure again during this buffering countdown, we will create an AccessCase object for it.
// That's not so bad - we'll get rid of the redundant ones once we regenerate.
- HashSet<BufferedStructure, BufferedStructure::Hash, BufferedStructure::KeyTraits> m_bufferedStructures;
+ HashSet<BufferedStructure, BufferedStructure::Hash, BufferedStructure::KeyTraits> m_bufferedStructures WTF_GUARDED_BY_LOCK(m_bufferedStructuresLock);
public:
CodeLocationLabel<JITStubRoutinePtrTag> start; // This is either the start of the inline IC for *byId caches. or the location of patchable jump for 'instanceof' caches.
CodeLocationLabel<JSInternalPtrTag> doneLocation;
@@ -391,7 +392,7 @@
bool propertyIsInt32 : 1;
bool propertyIsSymbol : 1;
private:
- Lock m_bufferedStructuresLock;
+ CheckedLock m_bufferedStructuresLock;
};
inline CodeOrigin getStructureStubInfoCodeOrigin(StructureStubInfo& structureStubInfo)
Modified: trunk/Source/_javascript_Core/bytecode/SuperSampler.cpp (277933 => 277934)
--- trunk/Source/_javascript_Core/bytecode/SuperSampler.cpp 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/_javascript_Core/bytecode/SuperSampler.cpp 2021-05-23 20:33:29 UTC (rev 277934)
@@ -27,8 +27,8 @@
#include "SuperSampler.h"
#include "Options.h"
+#include <wtf/CheckedLock.h>
#include <wtf/DataLog.h>
-#include <wtf/Lock.h>
#include <wtf/Threading.h>
namespace JSC {
@@ -36,9 +36,9 @@
volatile uint32_t g_superSamplerCount;
volatile bool g_superSamplerEnabled;
-static Lock lock;
-static double in;
-static double out;
+static CheckedLock lock;
+static double in WTF_GUARDED_BY_LOCK(lock);
+static double out WTF_GUARDED_BY_LOCK(lock);
void initializeSuperSampler()
{
Modified: trunk/Source/_javascript_Core/dfg/DFGCommonData.cpp (277933 => 277934)
--- trunk/Source/_javascript_Core/dfg/DFGCommonData.cpp 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/_javascript_Core/dfg/DFGCommonData.cpp 2021-05-23 20:33:29 UTC (rev 277934)
@@ -34,6 +34,7 @@
#include "InlineCallFrame.h"
#include "JSCJSValueInlines.h"
#include "TrackedReferences.h"
+#include <wtf/CheckedLock.h>
#include <wtf/NeverDestroyed.h>
namespace JSC { namespace DFG {
@@ -44,8 +45,8 @@
m_jumpReplacements.shrinkToFit();
}
-static Lock pcCodeBlockMapLock;
-inline HashMap<void*, CodeBlock*>& pcCodeBlockMap(AbstractLocker&)
+static CheckedLock pcCodeBlockMapLock;
+inline HashMap<void*, CodeBlock*>& pcCodeBlockMap() WTF_REQUIRES_LOCK(pcCodeBlockMapLock)
{
static LazyNeverDestroyed<HashMap<void*, CodeBlock*>> pcCodeBlockMap;
static std::once_flag onceKey;
@@ -62,7 +63,7 @@
if (UNLIKELY(hasVMTrapsBreakpointsInstalled)) {
Locker locker { pcCodeBlockMapLock };
- auto& map = pcCodeBlockMap(locker);
+ auto& map = pcCodeBlockMap();
for (auto& jumpReplacement : m_jumpReplacements)
map.remove(jumpReplacement.dataLocation());
hasVMTrapsBreakpointsInstalled = false;
@@ -78,7 +79,7 @@
{
if (UNLIKELY(hasVMTrapsBreakpointsInstalled)) {
Locker locker { pcCodeBlockMapLock };
- auto& map = pcCodeBlockMap(locker);
+ auto& map = pcCodeBlockMap();
for (auto& jumpReplacement : m_jumpReplacements)
map.remove(jumpReplacement.dataLocation());
}
@@ -91,7 +92,7 @@
return;
hasVMTrapsBreakpointsInstalled = true;
- auto& map = pcCodeBlockMap(locker);
+ auto& map = pcCodeBlockMap();
#if !defined(NDEBUG)
// We need to be able to handle more than one invalidation point at the same pc
// but we want to make sure we don't forget to remove a pc from the map.
@@ -113,7 +114,7 @@
{
ASSERT(isJITPC(pc));
Locker locker { pcCodeBlockMapLock };
- auto& map = pcCodeBlockMap(locker);
+ auto& map = pcCodeBlockMap();
auto result = map.find(pc);
if (result == map.end())
return nullptr;
Modified: trunk/Source/_javascript_Core/dfg/DFGPlan.h (277933 => 277934)
--- trunk/Source/_javascript_Core/dfg/DFGPlan.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/_javascript_Core/dfg/DFGPlan.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -38,6 +38,7 @@
#include "Operands.h"
#include "ProfilerCompilation.h"
#include "RecordedStatuses.h"
+#include <wtf/CheckedLock.h>
#include <wtf/HashMap.h>
#include <wtf/ThreadSafeRefCounted.h>
@@ -137,8 +138,8 @@
CodeBlock* m_profiledDFGCodeBlock;
Operands<Optional<JSValue>> m_mustHandleValues;
- bool m_mustHandleValuesMayIncludeGarbage { true };
- Lock m_mustHandleValueCleaningLock;
+ bool m_mustHandleValuesMayIncludeGarbage WTF_GUARDED_BY_LOCK(m_mustHandleValueCleaningLock) { true };
+ CheckedLock m_mustHandleValueCleaningLock;
bool m_willTryToTierUp { false };
Modified: trunk/Source/_javascript_Core/disassembler/Disassembler.cpp (277933 => 277934)
--- trunk/Source/_javascript_Core/disassembler/Disassembler.cpp 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/_javascript_Core/disassembler/Disassembler.cpp 2021-05-23 20:33:29 UTC (rev 277934)
@@ -27,10 +27,10 @@
#include "Disassembler.h"
#include "MacroAssemblerCodeRef.h"
-#include <wtf/Condition.h>
+#include <wtf/CheckedCondition.h>
+#include <wtf/CheckedLock.h>
#include <wtf/DataLog.h>
#include <wtf/Deque.h>
-#include <wtf/Lock.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/Threading.h>
@@ -109,9 +109,9 @@
}
}
- Lock m_lock;
- Condition m_condition;
- Deque<std::unique_ptr<DisassemblyTask>> m_queue;
+ CheckedLock m_lock;
+ CheckedCondition m_condition;
+ Deque<std::unique_ptr<DisassemblyTask>> m_queue WTF_GUARDED_BY_LOCK(m_lock);
bool m_working { false };
};
Modified: trunk/Source/_javascript_Core/heap/BlockDirectory.cpp (277933 => 277934)
--- trunk/Source/_javascript_Core/heap/BlockDirectory.cpp 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/_javascript_Core/heap/BlockDirectory.cpp 2021-05-23 20:33:29 UTC (rev 277934)
@@ -31,6 +31,7 @@
#include "SubspaceInlines.h"
#include "SuperSampler.h"
+#include <wtf/CheckedLock.h>
#include <wtf/FunctionTraits.h>
#include <wtf/SimpleStats.h>
@@ -343,9 +344,9 @@
}
private:
- BlockDirectory& m_directory;
- size_t m_index { 0 };
- Lock m_lock;
+ BlockDirectory& m_directory WTF_GUARDED_BY_LOCK(m_lock);
+ size_t m_index WTF_GUARDED_BY_LOCK(m_lock) { 0 };
+ CheckedLock m_lock;
bool m_done { false };
};
Modified: trunk/Source/_javascript_Core/heap/Heap.h (277933 => 277934)
--- trunk/Source/_javascript_Core/heap/Heap.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/_javascript_Core/heap/Heap.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -42,6 +42,7 @@
#include "Synchronousness.h"
#include "WeakHandleOwner.h"
#include <wtf/AutomaticThread.h>
+#include <wtf/CheckedLock.h>
#include <wtf/ConcurrentPtrHashSet.h>
#include <wtf/Deque.h>
#include <wtf/HashCountedSet.h>
@@ -648,7 +649,7 @@
// one GC to the next. GC marking threads claim these at the start of marking, and return
// them at the end.
Vector<std::unique_ptr<SlotVisitor>> m_parallelSlotVisitors;
- Vector<SlotVisitor*> m_availableParallelSlotVisitors;
+ Vector<SlotVisitor*> m_availableParallelSlotVisitors WTF_GUARDED_BY_LOCK(m_parallelSlotVisitorLock);
HandleSet m_handleSet;
std::unique_ptr<CodeBlockSet> m_codeBlocks;
@@ -656,7 +657,7 @@
CFinalizerOwner m_cFinalizerOwner;
LambdaFinalizerOwner m_lambdaFinalizerOwner;
- Lock m_parallelSlotVisitorLock;
+ CheckedLock m_parallelSlotVisitorLock;
bool m_isSafeToCollect { false };
bool m_isShuttingDown { false };
bool m_mutatorShouldBeFenced { Options::forceFencedBarrier() };
Modified: trunk/Source/_javascript_Core/heap/IsoSubspacePerVM.h (277933 => 277934)
--- trunk/Source/_javascript_Core/heap/IsoSubspacePerVM.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/_javascript_Core/heap/IsoSubspacePerVM.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -26,9 +26,9 @@
#pragma once
#include "IsoSubspace.h"
+#include <wtf/CheckedLock.h>
#include <wtf/Function.h>
#include <wtf/HashMap.h>
-#include <wtf/Lock.h>
namespace JSC {
@@ -62,8 +62,8 @@
class AutoremovingIsoSubspace;
friend class AutoremovingIsoSubspace;
- Lock m_lock;
- HashMap<VM*, IsoSubspace*> m_subspacePerVM;
+ CheckedLock m_lock;
+ HashMap<VM*, IsoSubspace*> m_subspacePerVM WTF_GUARDED_BY_LOCK(m_lock);
Function<SubspaceParameters(VM&)> m_subspaceParameters;
};
Modified: trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorConnectionClient.h (277933 => 277934)
--- trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorConnectionClient.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorConnectionClient.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -30,9 +30,9 @@
#include "RemoteControllableTarget.h"
#include "RemoteInspectorMessageParser.h"
#include "RemoteInspectorSocketEndpoint.h"
+#include <wtf/CheckedLock.h>
#include <wtf/HashMap.h>
#include <wtf/JSONValues.h>
-#include <wtf/Lock.h>
#include <wtf/text/WTFString.h>
namespace Inspector {
@@ -65,8 +65,8 @@
static Optional<Event> extractEvent(ConnectionID, Vector<uint8_t>&&);
- HashMap<ConnectionID, MessageParser> m_parsers;
- Lock m_parsersLock;
+ HashMap<ConnectionID, MessageParser> m_parsers WTF_GUARDED_BY_LOCK(m_parsersLock);
+ CheckedLock m_parsersLock;
};
} // namespace Inspector
Modified: trunk/Source/WebCore/ChangeLog (277933 => 277934)
--- trunk/Source/WebCore/ChangeLog 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/ChangeLog 2021-05-23 20:33:29 UTC (rev 277934)
@@ -1,5 +1,36 @@
2021-05-23 Chris Dumez <cdu...@apple.com>
+ Use CheckedLock in even more places
+ https://bugs.webkit.org/show_bug.cgi?id=226152
+
+ Reviewed by Darin Adler.
+
+ Use CheckedLock in even more places to benefit from Clang Thread Safety Analysis.
+
+ * platform/image-decoders/ScalableImageDecoder.cpp:
+ (WebCore::ScalableImageDecoder::frameIsCompleteAtIndex const):
+ (WebCore::ScalableImageDecoder::frameHasAlphaAtIndex const):
+ (WebCore::ScalableImageDecoder::frameBytesAtIndex const):
+ (WebCore::ScalableImageDecoder::frameDurationAtIndex const):
+ (WebCore::ScalableImageDecoder::createFrameImageAtIndex):
+ * platform/image-decoders/ScalableImageDecoder.h:
+ * platform/mediarecorder/MediaRecorderPrivateMock.h:
+ * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h:
+ * platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:
+ * platform/mediastream/RealtimeMediaSource.h:
+ * platform/mediastream/RealtimeOutgoingAudioSource.h:
+ * platform/mediastream/RealtimeOutgoingVideoSource.h:
+ * platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp:
+ (WebCore::RealtimeOutgoingAudioSourceLibWebRTC::audioSamplesAvailable):
+ (WebCore::RealtimeOutgoingAudioSourceLibWebRTC::pullAudioData):
+ * platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h:
+ * platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp:
+ * platform/mediastream/mac/AVVideoCaptureSource.h:
+ * platform/sql/SQLiteDatabase.h:
+ * worklets/PaintWorkletGlobalScope.h:
+
+2021-05-23 Chris Dumez <cdu...@apple.com>
+
Drop WTF::tryHoldLock() as it is incompatible with Clang Thread Safety Analysis
https://bugs.webkit.org/show_bug.cgi?id=226145
Modified: trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp (277933 => 277934)
--- trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp 2021-05-23 20:33:29 UTC (rev 277934)
@@ -170,7 +170,7 @@
bool ScalableImageDecoder::frameIsCompleteAtIndex(size_t index) const
{
- Locker locker { m_mutex };
+ Locker locker { m_lock };
if (index >= m_frameBufferCache.size())
return false;
@@ -180,7 +180,7 @@
bool ScalableImageDecoder::frameHasAlphaAtIndex(size_t index) const
{
- Locker locker { m_mutex };
+ Locker locker { m_lock };
if (m_frameBufferCache.size() <= index)
return true;
@@ -192,7 +192,7 @@
unsigned ScalableImageDecoder::frameBytesAtIndex(size_t index, SubsamplingLevel) const
{
- Locker locker { m_mutex };
+ Locker locker { m_lock };
if (m_frameBufferCache.size() <= index)
return 0;
// FIXME: Use the dimension of the requested frame.
@@ -201,7 +201,7 @@
Seconds ScalableImageDecoder::frameDurationAtIndex(size_t index) const
{
- Locker locker { m_mutex };
+ Locker locker { m_lock };
if (index >= m_frameBufferCache.size())
return 0_s;
@@ -221,7 +221,7 @@
PlatformImagePtr ScalableImageDecoder::createFrameImageAtIndex(size_t index, SubsamplingLevel, const DecodingOptions&)
{
- Locker locker { m_mutex };
+ Locker locker { m_lock };
// Zero-height images can cause problems for some ports. If we have an empty image dimension, just bail.
if (size().isEmpty())
return nullptr;
Modified: trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h (277933 => 277934)
--- trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -33,7 +33,7 @@
#include "ScalableImageDecoderFrame.h"
#include "SharedBuffer.h"
#include <wtf/Assertions.h>
-#include <wtf/Lock.h>
+#include <wtf/CheckedLock.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
@@ -72,7 +72,7 @@
void setData(SharedBuffer& data, bool allDataReceived) override
{
- Locker locker { m_mutex };
+ Locker locker { m_lock };
if (m_encodedDataStatus == EncodedDataStatus::Error)
return;
@@ -196,8 +196,8 @@
protected:
RefPtr<SharedBuffer::DataSegment> m_data;
- Vector<ScalableImageDecoderFrame, 1> m_frameBufferCache;
- mutable Lock m_mutex;
+ Vector<ScalableImageDecoderFrame, 1> m_frameBufferCache WTF_GUARDED_BY_LOCK(m_lock);
+ mutable CheckedLock m_lock;
bool m_premultiplyAlpha;
bool m_ignoreGammaAndColorProfile;
ImageOrientation m_orientation;
Modified: trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h (277933 => 277934)
--- trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/platform/mediarecorder/MediaRecorderPrivateMock.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -27,7 +27,7 @@
#if ENABLE(MEDIA_STREAM)
#include "MediaRecorderPrivate.h"
-#include <wtf/Lock.h>
+#include <wtf/CheckedLock.h>
#include <wtf/text/StringBuilder.h>
namespace WebCore {
@@ -50,10 +50,10 @@
void resumeRecording(CompletionHandler<void()>&&) final;
const String& mimeType() const final;
- void generateMockCounterString();
+ void generateMockCounterString() WTF_REQUIRES_LOCK(m_bufferLock);
- mutable Lock m_bufferLock;
- StringBuilder m_buffer;
+ mutable CheckedLock m_bufferLock;
+ StringBuilder m_buffer WTF_GUARDED_BY_LOCK(m_bufferLock);
unsigned m_counter { 0 };
String m_audioTrackID;
String m_videoTrackID;
Modified: trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h (277933 => 277934)
--- trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -29,9 +29,9 @@
#include "AudioStreamDescription.h"
#include "SharedBuffer.h"
+#include <wtf/CheckedLock.h>
#include <wtf/CompletionHandler.h>
#include <wtf/Deque.h>
-#include <wtf/Lock.h>
#include <wtf/RetainPtr.h>
#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/WeakPtr.h>
@@ -118,8 +118,8 @@
RetainPtr<AVAssetWriter> m_writer;
- Lock m_dataLock;
- RefPtr<SharedBuffer> m_data;
+ CheckedLock m_dataLock;
+ RefPtr<SharedBuffer> m_data WTF_GUARDED_BY_LOCK(m_dataLock);
CompletionHandler<void(RefPtr<SharedBuffer>&&, double)> m_fetchDataCompletionHandler;
RetainPtr<CMFormatDescriptionRef> m_audioFormatDescription;
Modified: trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm (277933 => 277934)
--- trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm 2021-05-23 20:33:29 UTC (rev 277934)
@@ -370,7 +370,8 @@
[m_videoAssetWriterInput requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:block.get()];
}
-void MediaRecorderPrivateWriter::clear()
+// FIXME: This modifies m_data without grabbing m_dataLock.
+void MediaRecorderPrivateWriter::clear() WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
m_pendingAudioSampleQueue.clear();
m_pendingVideoSampleQueue.clear();
Modified: trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h (277933 => 277934)
--- trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeMediaSource.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -42,8 +42,8 @@
#include "PlatformLayer.h"
#include "RealtimeMediaSourceCapabilities.h"
#include "RealtimeMediaSourceFactory.h"
+#include <wtf/CheckedLock.h>
#include <wtf/CompletionHandler.h>
-#include <wtf/Lock.h>
#include <wtf/LoggerHelper.h>
#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/Vector.h>
@@ -276,11 +276,11 @@
String m_name;
WeakHashSet<Observer> m_observers;
- mutable Lock m_audioSampleObserversLock;
- HashSet<AudioSampleObserver*> m_audioSampleObservers;
+ mutable CheckedLock m_audioSampleObserversLock;
+ HashSet<AudioSampleObserver*> m_audioSampleObservers WTF_GUARDED_BY_LOCK(m_audioSampleObserversLock);
- mutable Lock m_videoSampleObserversLock;
- HashSet<VideoSampleObserver*> m_videoSampleObservers;
+ mutable CheckedLock m_videoSampleObserversLock;
+ HashSet<VideoSampleObserver*> m_videoSampleObservers WTF_GUARDED_BY_LOCK(m_videoSampleObserversLock);
// Set on the main thread from constraints.
IntSize m_size;
Modified: trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingAudioSource.h (277933 => 277934)
--- trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingAudioSource.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingAudioSource.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -41,6 +41,7 @@
ALLOW_UNUSED_PARAMETERS_END
+#include <wtf/CheckedLock.h>
#include <wtf/LoggerHelper.h>
#include <wtf/ThreadSafeRefCounted.h>
@@ -127,8 +128,8 @@
bool m_muted { false };
bool m_enabled { true };
- mutable Lock m_sinksLock;
- HashSet<webrtc::AudioTrackSinkInterface*> m_sinks;
+ mutable CheckedLock m_sinksLock;
+ HashSet<webrtc::AudioTrackSinkInterface*> m_sinks WTF_GUARDED_BY_LOCK(m_sinksLock);
#if !RELEASE_LOG_DISABLED
size_t m_chunksSent { 0 };
Modified: trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.h (277933 => 277934)
--- trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -33,6 +33,7 @@
#include "LibWebRTCMacros.h"
#include "MediaStreamTrackPrivate.h"
#include <Timer.h>
+#include <wtf/CheckedLock.h>
ALLOW_UNUSED_PARAMETERS_BEGIN
@@ -141,8 +142,8 @@
Timer m_blackFrameTimer;
rtc::scoped_refptr<webrtc::VideoFrameBuffer> m_blackFrame;
- mutable Lock m_sinksLock;
- HashSet<rtc::VideoSinkInterface<webrtc::VideoFrame>*> m_sinks;
+ mutable CheckedLock m_sinksLock;
+ HashSet<rtc::VideoSinkInterface<webrtc::VideoFrame>*> m_sinks WTF_GUARDED_BY_LOCK(m_sinksLock);
bool m_areSinksAskingToApplyRotation { false };
bool m_enabled { true };
Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp (277933 => 277934)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.cpp 2021-05-23 20:33:29 UTC (rev 277934)
@@ -81,7 +81,7 @@
}
{
- Locker locker { m_adapterMutex };
+ Locker locker { m_adapterLock };
const auto& sample = data.getSample();
auto* buffer = gst_sample_get_buffer(sample.get());
gst_adapter_push(m_adapter.get(), gst_buffer_ref(buffer));
@@ -101,7 +101,7 @@
size_t outChunkSampleCount = LibWebRTCAudioFormat::chunkSampleCount;
size_t outBufferSize = outChunkSampleCount * m_outputStreamDescription.bpf;
- Locker locker { m_adapterMutex };
+ Locker locker { m_adapterLock };
size_t inChunkSampleCount = gst_audio_converter_get_in_frames(m_sampleConverter.get(), outChunkSampleCount);
size_t inBufferSize = inChunkSampleCount * m_inputStreamDescription.bpf;
Modified: trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h (277933 => 277934)
--- trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceLibWebRTC.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -25,6 +25,7 @@
#include "RealtimeOutgoingAudioSource.h"
#include <gst/audio/audio.h>
+#include <wtf/CheckedLock.h>
namespace WebCore {
@@ -51,8 +52,8 @@
GstAudioInfo m_inputStreamDescription;
GstAudioInfo m_outputStreamDescription;
- Lock m_adapterMutex;
- GRefPtr<GstAdapter> m_adapter;
+ CheckedLock m_adapterLock;
+ GRefPtr<GstAdapter> m_adapter WTF_GUARDED_BY_LOCK(m_adapterLock);
Vector<uint8_t> m_audioBuffer;
};
Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp (277933 => 277934)
--- trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoEncoderFactory.cpp 2021-05-23 20:33:29 UTC (rev 277934)
@@ -345,7 +345,6 @@
GRefPtr<GstCaps> m_restrictionCaps;
webrtc::EncodedImage m_encodedFrame;
- Lock m_bufferMapLock;
GRefPtr<GstElement> m_sink;
};
Modified: trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h (277933 => 277934)
--- trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -132,7 +132,6 @@
RetainPtr<AVCaptureSession> m_session;
RetainPtr<AVCaptureDevice> m_device;
- Lock m_presetMutex;
RefPtr<AVVideoPreset> m_currentPreset;
IntSize m_currentSize;
double m_currentFrameRate;
Modified: trunk/Source/WebCore/platform/sql/SQLiteDatabase.h (277933 => 277934)
--- trunk/Source/WebCore/platform/sql/SQLiteDatabase.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/platform/sql/SQLiteDatabase.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -28,8 +28,8 @@
#include <functional>
#include <sqlite3.h>
+#include <wtf/CheckedLock.h>
#include <wtf/Expected.h>
-#include <wtf/Lock.h>
#include <wtf/Threading.h>
#include <wtf/UniqueRef.h>
#include <wtf/WeakPtr.h>
@@ -162,7 +162,7 @@
private:
static int authorizerFunction(void*, int, const char*, const char*, const char*, const char*);
- void enableAuthorizer(bool enable);
+ void enableAuthorizer(bool enable) WTF_REQUIRES_LOCK(m_authorizerLock);
void useWALJournalMode();
int pageSize();
@@ -180,8 +180,8 @@
bool m_useWAL { false };
- Lock m_authorizerLock;
- RefPtr<DatabaseAuthorizer> m_authorizer;
+ CheckedLock m_authorizerLock;
+ RefPtr<DatabaseAuthorizer> m_authorizer WTF_GUARDED_BY_LOCK(m_authorizerLock);
Lock m_lockingMutex;
RefPtr<Thread> m_openingThread { nullptr };
Modified: trunk/Source/WebCore/worklets/PaintWorkletGlobalScope.h (277933 => 277934)
--- trunk/Source/WebCore/worklets/PaintWorkletGlobalScope.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebCore/worklets/PaintWorkletGlobalScope.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -31,6 +31,7 @@
#include "WorkletGlobalScope.h"
#include <_javascript_Core/JSObject.h>
#include <_javascript_Core/Strong.h>
+#include <wtf/CheckedLock.h>
namespace JSC {
class JSObject;
@@ -60,8 +61,8 @@
const Vector<String> inputArguments;
};
- HashMap<String, std::unique_ptr<PaintDefinition>>& paintDefinitionMap() { ASSERT(m_paintDefinitionLock.isLocked()); return m_paintDefinitionMap; }
- Lock& paintDefinitionLock() { return m_paintDefinitionLock; }
+ HashMap<String, std::unique_ptr<PaintDefinition>>& paintDefinitionMap() WTF_REQUIRES_LOCK(m_paintDefinitionLock);
+ CheckedLock& paintDefinitionLock() WTF_RETURNS_LOCK(m_paintDefinitionLock) { return m_paintDefinitionLock; }
void prepareForDestruction() final
{
@@ -91,11 +92,17 @@
bool isPaintWorkletGlobalScope() const final { return true; }
- HashMap<String, std::unique_ptr<PaintDefinition>> m_paintDefinitionMap;
- Lock m_paintDefinitionLock;
+ HashMap<String, std::unique_ptr<PaintDefinition>> m_paintDefinitionMap WTF_GUARDED_BY_LOCK(m_paintDefinitionLock);
+ CheckedLock m_paintDefinitionLock;
bool m_hasPreparedForDestruction { false };
};
+inline auto PaintWorkletGlobalScope::paintDefinitionMap() -> HashMap<String, std::unique_ptr<PaintDefinition>>&
+{
+ ASSERT(m_paintDefinitionLock.isLocked());
+ return m_paintDefinitionMap;
+}
+
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::PaintWorkletGlobalScope)
Modified: trunk/Source/WebKit/ChangeLog (277933 => 277934)
--- trunk/Source/WebKit/ChangeLog 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebKit/ChangeLog 2021-05-23 20:33:29 UTC (rev 277934)
@@ -1,3 +1,26 @@
+2021-05-23 Chris Dumez <cdu...@apple.com>
+
+ Use CheckedLock in even more places
+ https://bugs.webkit.org/show_bug.cgi?id=226152
+
+ Reviewed by Darin Adler.
+
+ Use CheckedLock in even more places to benefit from Clang Thread Safety Analysis.
+
+ * GPUProcess/webrtc/LibWebRTCCodecsProxy.h:
+ * GPUProcess/webrtc/LibWebRTCCodecsProxy.mm:
+ * NetworkProcess/glib/DNSCache.h:
+ * Shared/mac/MediaFormatReader/MediaSampleCursor.cpp:
+ (WebKit::MediaSampleCursor::locateIterator const):
+ (WebKit::MediaSampleCursor::locateMediaSample const):
+ (WebKit::MediaSampleCursor::locateTiming const):
+ (WebKit::MediaSampleCursor::stepInOrderedMap):
+ (WebKit::MediaSampleCursor::stepInPresentationTime):
+ (WebKit::MediaSampleCursor::getMediaSample const):
+ (WebKit::MediaSampleCursor::getTiming const):
+ (WebKit::MediaSampleCursor::getPlayableHorizon const):
+ * Shared/mac/MediaFormatReader/MediaSampleCursor.h:
+
2021-05-22 Wenson Hsieh <wenson_hs...@apple.com>
[iOS] Implement page client hook for requesting image extraction results
Modified: trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h (277933 => 277934)
--- trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -32,6 +32,7 @@
#include "RTCDecoderIdentifier.h"
#include "RTCEncoderIdentifier.h"
#include <WebCore/ImageTransferSessionVT.h>
+#include <wtf/CheckedLock.h>
namespace IPC {
class Connection;
@@ -87,9 +88,9 @@
GPUConnectionToWebProcess& m_gpuConnectionToWebProcess;
- mutable Lock m_lock;
- HashMap<RTCDecoderIdentifier, webrtc::LocalDecoder> m_decoders;
- HashMap<RTCEncoderIdentifier, webrtc::LocalEncoder> m_encoders;
+ mutable CheckedLock m_lock;
+ HashMap<RTCDecoderIdentifier, webrtc::LocalDecoder> m_decoders WTF_GUARDED_BY_LOCK(m_lock); // Only modified on the libWebRTCCodecsQueue but may get accessed from the main thread.
+ HashMap<RTCEncoderIdentifier, webrtc::LocalEncoder> m_encoders WTF_GUARDED_BY_LOCK(m_lock); // Only modified on the libWebRTCCodecsQueue but may get accessed from the main thread.
Ref<WorkQueue> m_queue;
std::unique_ptr<WebCore::ImageTransferSessionVT> m_imageTransferSession;
Modified: trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm (277933 => 277934)
--- trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebKit/GPUProcess/webrtc/LibWebRTCCodecsProxy.mm 2021-05-23 20:33:29 UTC (rev 277934)
@@ -115,7 +115,9 @@
webrtc::releaseLocalDecoder(decoder);
}
-void LibWebRTCCodecsProxy::decodeFrame(RTCDecoderIdentifier identifier, uint32_t timeStamp, const IPC::DataReference& data)
+// For performance reasons, this function accesses m_decoders without locking. This is safe because this function runs on the libWebRTCCodecsQueue
+// and m_decoders only get modified on this queue.
+void LibWebRTCCodecsProxy::decodeFrame(RTCDecoderIdentifier identifier, uint32_t timeStamp, const IPC::DataReference& data) WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
ASSERT(!isMainRunLoop());
ASSERT(m_decoders.contains(identifier));
@@ -127,7 +129,9 @@
m_gpuConnectionToWebProcess.connection().send(Messages::LibWebRTCCodecs::FailedDecoding { identifier }, 0);
}
-void LibWebRTCCodecsProxy::setFrameSize(RTCDecoderIdentifier identifier, uint16_t width, uint16_t height)
+// For performance reasons, this function accesses m_decoders without locking. This is safe because this function runs on the libWebRTCCodecsQueue
+// and m_decoders only get modified on this queue.
+void LibWebRTCCodecsProxy::setFrameSize(RTCDecoderIdentifier identifier, uint16_t width, uint16_t height) WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
ASSERT(!isMainRunLoop());
ASSERT(m_decoders.contains(identifier));
@@ -164,7 +168,9 @@
webrtc::releaseLocalEncoder(encoder);
}
-void LibWebRTCCodecsProxy::initializeEncoder(RTCEncoderIdentifier identifier, uint16_t width, uint16_t height, unsigned startBitrate, unsigned maxBitrate, unsigned minBitrate, uint32_t maxFramerate)
+// For performance reasons, this function accesses m_encoders without locking. This is safe because this function runs on the libWebRTCCodecsQueue
+// and m_encoders only get modified on this queue.
+void LibWebRTCCodecsProxy::initializeEncoder(RTCEncoderIdentifier identifier, uint16_t width, uint16_t height, unsigned startBitrate, unsigned maxBitrate, unsigned minBitrate, uint32_t maxFramerate) WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
ASSERT(!isMainRunLoop());
ASSERT(m_encoders.contains(identifier));
@@ -191,7 +197,9 @@
return webrtc::kVideoRotation_0;
}
-void LibWebRTCCodecsProxy::encodeFrame(RTCEncoderIdentifier identifier, WebCore::RemoteVideoSample&& sample, uint32_t timeStamp, bool shouldEncodeAsKeyFrame)
+// For performance reasons, this function accesses m_encoders without locking. This is safe because this function runs on the libWebRTCCodecsQueue
+// and m_encoders only get modified on this queue.
+void LibWebRTCCodecsProxy::encodeFrame(RTCEncoderIdentifier identifier, WebCore::RemoteVideoSample&& sample, uint32_t timeStamp, bool shouldEncodeAsKeyFrame) WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
ASSERT(!isMainRunLoop());
ASSERT(m_encoders.contains(identifier));
@@ -208,7 +216,9 @@
#endif
}
-void LibWebRTCCodecsProxy::setEncodeRates(RTCEncoderIdentifier identifier, uint32_t bitRate, uint32_t frameRate)
+// For performance reasons, this function accesses m_encoders without locking. This is safe because this function runs on the libWebRTCCodecsQueue
+// and m_encoders only get modified on this queue.
+void LibWebRTCCodecsProxy::setEncodeRates(RTCEncoderIdentifier identifier, uint32_t bitRate, uint32_t frameRate) WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
ASSERT(!isMainRunLoop());
auto encoder = m_encoders.get(identifier);
Modified: trunk/Source/WebKit/NetworkProcess/glib/DNSCache.h (277933 => 277934)
--- trunk/Source/WebKit/NetworkProcess/glib/DNSCache.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebKit/NetworkProcess/glib/DNSCache.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -25,8 +25,8 @@
#pragma once
+#include <wtf/CheckedLock.h>
#include <wtf/HashMap.h>
-#include <wtf/Lock.h>
#include <wtf/MonotonicTime.h>
#include <wtf/Optional.h>
#include <wtf/RunLoop.h>
@@ -56,13 +56,13 @@
using DNSCacheMap = HashMap<CString, CachedResponse>;
- DNSCacheMap& mapForType(Type);
+ DNSCacheMap& mapForType(Type) WTF_REQUIRES_LOCK(m_lock);
void removeExpiredResponsesFired();
void removeExpiredResponsesInMap(DNSCacheMap&);
void pruneResponsesInMap(DNSCacheMap&);
- Lock m_lock;
- DNSCacheMap m_dnsMap;
+ CheckedLock m_lock;
+ DNSCacheMap m_dnsMap WTF_GUARDED_BY_LOCK(m_lock);
#if GLIB_CHECK_VERSION(2, 59, 0)
DNSCacheMap m_ipv4Map;
DNSCacheMap m_ipv6Map;
Modified: trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaSampleCursor.cpp (277933 => 277934)
--- trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaSampleCursor.cpp 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaSampleCursor.cpp 2021-05-23 20:33:29 UTC (rev 277934)
@@ -145,6 +145,7 @@
using Iterator = typename OrderedMap::iterator;
return WTF::switchOn(m_locator,
[&](const MediaTime& presentationTime) -> Optional<Iterator> {
+ assertIsHeld(m_locatorLock);
auto iterator = upperBound(samples, presentationTime);
if (iterator == samples.begin())
m_locator = WTFMove(iterator);
@@ -155,6 +156,7 @@
return locateIterator(samples, hasAllSamples);
},
[&](const auto& otherIterator) {
+ assertIsHeld(m_locatorLock);
m_locator = otherIterator->second->presentationTime();
return locateIterator(samples, hasAllSamples);
},
@@ -169,6 +171,7 @@
ASSERT(m_locatorLock.isLocked());
return WTF::switchOn(m_locator,
[&](const MediaTime&) -> MediaSample* {
+ assertIsHeld(m_locatorLock);
auto iterator = locateIterator(samples.presentationOrder(), hasAllSamples);
if (!iterator)
return nullptr;
@@ -185,6 +188,7 @@
ASSERT(m_locatorLock.isLocked());
return WTF::switchOn(m_locator,
[&](const MediaTime& presentationTime) {
+ assertIsHeld(m_locatorLock);
if (locateMediaSample(samples, hasAllSamples))
return locateTiming(samples, hasAllSamples);
auto& clampedPresentationTime = std::min(presentationTime, m_trackReader->duration());
@@ -208,6 +212,7 @@
OSStatus MediaSampleCursor::stepInOrderedMap(int64_t stepsToTake, int64_t& stepsTaken)
{
return getSampleMap([&](SampleMap& samples, bool hasAllSamples) -> OSStatus {
+ assertIsHeld(m_locatorLock);
auto& orderedMap = orderedSamples<OrderedMap>(samples);
if (auto iterator = locateIterator(orderedMap, hasAllSamples)) {
auto stepsRemaining = stepIterator(stepsToTake, *iterator, orderedMap);
@@ -222,6 +227,7 @@
OSStatus MediaSampleCursor::stepInPresentationTime(const MediaTime& delta, Boolean& wasPinned)
{
return getSampleMap([&](SampleMap& samples, bool hasAllSamples) -> OSStatus {
+ assertIsHeld(m_locatorLock);
auto timing = locateTiming(samples, hasAllSamples);
wasPinned = stepTime(delta, timing.presentationTime, samples.presentationOrder(), hasAllSamples, m_trackReader->duration());
m_locator = timing.presentationTime;
@@ -247,6 +253,7 @@
OSStatus MediaSampleCursor::getMediaSample(Function&& function) const
{
return getSampleMap([&](SampleMap& samples, bool hasAllSamples) -> OSStatus {
+ assertIsHeld(m_locatorLock);
auto sample = locateMediaSample(samples, hasAllSamples);
if (!sample)
return kMTPluginSampleCursorError_LocationNotAvailable;
@@ -260,6 +267,7 @@
OSStatus MediaSampleCursor::getTiming(Function&& function) const
{
return getSampleMap([&](SampleMap& samples, bool hasAllSamples) {
+ assertIsHeld(m_locatorLock);
auto timing = locateTiming(samples, hasAllSamples);
DEBUG_LOG(LOGIDENTIFIER, "decodeTime: ", timing.decodeTime, ", presentationTime: ", timing.presentationTime, ", duration: ", timing.duration);
function(timing);
@@ -382,6 +390,7 @@
OSStatus MediaSampleCursor::getPlayableHorizon(CMTime* playableHorizon) const
{
return getSampleMap([&](SampleMap& samples, bool hasAllSamples) {
+ assertIsHeld(m_locatorLock);
MediaSample& lastSample = *samples.decodeOrder().rbegin()->second;
auto timing = locateTiming(samples, hasAllSamples);
*playableHorizon = PAL::toCMTime(lastSample.presentationTime() + lastSample.duration() - timing.presentationTime);
Modified: trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaSampleCursor.h (277933 => 277934)
--- trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaSampleCursor.h 2021-05-23 20:15:29 UTC (rev 277933)
+++ trunk/Source/WebKit/Shared/mac/MediaFormatReader/MediaSampleCursor.h 2021-05-23 20:33:29 UTC (rev 277934)
@@ -29,6 +29,7 @@
#include "CoreMediaWrapped.h"
#include <WebCore/SampleMap.h>
+#include <wtf/CheckedLock.h>
#include <wtf/MediaTime.h>
#include <wtf/Variant.h>
@@ -71,9 +72,9 @@
MediaSampleCursor(Allocator&&, MediaTrackReader&, Locator);
MediaSampleCursor(Allocator&&, const MediaSampleCursor&);
- template<typename OrderedMap> Optional<typename OrderedMap::iterator> locateIterator(OrderedMap&, bool hasAllSamples) const;
- WebCore::MediaSample* locateMediaSample(WebCore::SampleMap&, bool hasAllSamples) const;
- Timing locateTiming(WebCore::SampleMap&, bool hasAllSamples) const;
+ template<typename OrderedMap> Optional<typename OrderedMap::iterator> locateIterator(OrderedMap&, bool hasAllSamples) const WTF_REQUIRES_LOCK(m_locatorLock);
+ WebCore::MediaSample* locateMediaSample(WebCore::SampleMap&, bool hasAllSamples) const WTF_REQUIRES_LOCK(m_locatorLock);
+ Timing locateTiming(WebCore::SampleMap&, bool hasAllSamples) const WTF_REQUIRES_LOCK(m_locatorLock);
template<typename Function> OSStatus getSampleMap(Function&&) const;
template<typename Function> OSStatus getMediaSample(Function&&) const;
@@ -105,8 +106,8 @@
WTFLogChannel& logChannel() const;
Ref<MediaTrackReader> m_trackReader;
- mutable Locator m_locator;
- mutable Lock m_locatorLock;
+ mutable Locator m_locator WTF_GUARDED_BY_LOCK(m_locatorLock);
+ mutable CheckedLock m_locatorLock;
Ref<const WTF::Logger> m_logger;
const void* m_logIdentifier;
};