aboutsummaryrefslogtreecommitdiff
path: root/www/waterfox/files/patch-bug1402681
blob: 6fddbdf9937df29cb887ac95ed201dd593b725e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
commit ffcf40b7a0e9
Author: Alastor Wu <alwu@mozilla.com>
Date:   Tue Sep 26 17:48:19 2017 +0800

    Bug 1402681 - Part 1: Do not queue the task without task queue. r=jya, a=sledru
    
    Since the source buffer is a wrapped native, it would be unlinked twice and then the
    TrackBuffersManager::Detach() would also be called twice.
    
    The first detach task would clear the task queue of TrackBuffersManager, and then we
    won't accept any new task without task queue. The second detach task should not be
    executed.
    
    MozReview-Commit-ID: AWTzVbRH5B1
    
    --HG--
    extra : source : 145eac8ba70636cdb1a235d6d7094b87bbfd8022
---
 dom/media/mediasource/TrackBuffersManager.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git dom/media/mediasource/TrackBuffersManager.cpp dom/media/mediasource/TrackBuffersManager.cpp
index 50293810064b..cda89faaff51 100644
--- dom/media/mediasource/TrackBuffersManager.cpp
+++ dom/media/mediasource/TrackBuffersManager.cpp
@@ -145,6 +145,15 @@ TrackBuffersManager::DoAppendData(already_AddRefed<MediaByteBuffer> aData,
 void
 TrackBuffersManager::QueueTask(SourceBufferTask* aTask)
 {
+  // The source buffer is a wrapped native, it would be unlinked twice and so
+  // the TrackBuffersManager::Detach() would also be called twice. Since the
+  // detach task has been done before, we could ignore this task.
+  if (!GetTaskQueue()) {
+    MOZ_ASSERT(aTask->GetType() == SourceBufferTask::Type::Detach,
+               "only detach task could happen here!");
+    return;
+  }
+
   if (!OnTaskQueue()) {
     GetTaskQueue()->Dispatch(NewRunnableMethod<RefPtr<SourceBufferTask>>(
       "TrackBuffersManager::QueueTask",

commit 99e2204da6a1
Author: Alastor Wu <alwu@mozilla.com>
Date:   Tue Sep 26 17:48:39 2017 +0800

    Bug 1402681 - Part 2: Add log. r=jya, a=sledru
    
    MozReview-Commit-ID: 8qINxSCKrvg
    
    --HG--
    extra : source : 0cac2e15b4ca7cf03e75ee208da624495215382f
---
 dom/media/mediasource/SourceBufferTask.h      | 7 +++++++
 dom/media/mediasource/TrackBuffersManager.cpp | 4 ++++
 2 files changed, 11 insertions(+)

diff --git dom/media/mediasource/SourceBufferTask.h dom/media/mediasource/SourceBufferTask.h
index 183e7b4b2a0b..b73094fbd282 100644
--- dom/media/mediasource/SourceBufferTask.h
+++ dom/media/mediasource/SourceBufferTask.h
@@ -32,6 +32,7 @@ public:
   typedef MozPromise<bool, nsresult, /* IsExclusive = */ true> RangeRemovalPromise;
 
   virtual Type GetType() const = 0;
+  virtual const char* GetTypeName() const = 0;
 
   template<typename ReturnType>
   ReturnType* As()
@@ -54,6 +55,7 @@ public:
 
   static const Type sType = Type::AppendBuffer;
   Type GetType() const override { return Type::AppendBuffer; }
+  const char* GetTypeName() const override { return "AppendBuffer"; }
 
   RefPtr<MediaByteBuffer> mBuffer;
   SourceBufferAttributes mAttributes;
@@ -64,12 +66,14 @@ class AbortTask : public SourceBufferTask {
 public:
   static const Type sType = Type::Abort;
   Type GetType() const override { return Type::Abort; }
+  const char* GetTypeName() const override { return "Abort"; }
 };
 
 class ResetTask : public SourceBufferTask {
 public:
   static const Type sType = Type::Reset;
   Type GetType() const override { return Type::Reset; }
+  const char* GetTypeName() const override { return "Reset"; }
 };
 
 class RangeRemovalTask : public SourceBufferTask {
@@ -80,6 +84,7 @@ public:
 
   static const Type sType = Type::RangeRemoval;
   Type GetType() const override { return Type::RangeRemoval; }
+  const char* GetTypeName() const override { return "RangeRemoval"; }
 
   media::TimeInterval mRange;
   MozPromiseHolder<RangeRemovalPromise> mPromise;
@@ -94,6 +99,7 @@ public:
 
   static const Type sType = Type::EvictData;
   Type GetType() const override { return Type::EvictData; }
+  const char* GetTypeName() const override { return "EvictData"; }
 
   media::TimeUnit mPlaybackTime;
   int64_t mSizeToEvict;
@@ -103,6 +109,7 @@ class DetachTask : public SourceBufferTask {
 public:
   static const Type sType = Type::Detach;
   Type GetType() const override { return Type::Detach; }
+  const char* GetTypeName() const override { return "Detach"; }
 };
 
 } // end mozilla namespace
diff --git dom/media/mediasource/TrackBuffersManager.cpp dom/media/mediasource/TrackBuffersManager.cpp
index cda89faaff51..b9b768b726a2 100644
--- dom/media/mediasource/TrackBuffersManager.cpp
+++ dom/media/mediasource/TrackBuffersManager.cpp
@@ -151,6 +151,8 @@ TrackBuffersManager::QueueTask(SourceBufferTask* aTask)
   if (!GetTaskQueue()) {
     MOZ_ASSERT(aTask->GetType() == SourceBufferTask::Type::Detach,
                "only detach task could happen here!");
+    MSE_DEBUG("Could not queue the task '%s' without task queue",
+              aTask->GetTypeName());
     return;
   }
 
@@ -183,6 +185,8 @@ TrackBuffersManager::ProcessTasks()
     // nothing to do.
     return;
   }
+
+  MSE_DEBUG("Process task '%s'", task->GetTypeName());
   switch (task->GetType()) {
     case Type::AppendBuffer:
       mCurrentTask = task;