Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Unified Diff: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp

Issue 2498033002: Media element: avoid v8 allocations in hasPendingActivity(). (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
index c812addeafe4fcdf05b0df3990075b6e0e1ce6d5..1e035b6610f7b7a8f55b940cf34037239c340486 100644
--- a/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLMediaElement.cpp
@@ -283,6 +283,22 @@ String preloadTypeToString(WebMediaPlayer::Preload preloadType) {
return String();
}
+class DisablePlaybackPositionUpdateScope {
+ STACK_ALLOCATED();
+
+ public:
+ DisablePlaybackPositionUpdateScope(bool* flag)
+ : m_flag(flag), m_value(*flag) {
+ *m_flag = false;
+ }
+
+ ~DisablePlaybackPositionUpdateScope() { *m_flag = m_value; }
+
+ private:
+ bool* m_flag;
+ bool m_value;
+};
+
} // anonymous namespace
class HTMLMediaElement::AutoplayHelperClientImpl
@@ -3458,9 +3474,17 @@ bool HTMLMediaElement::hasPendingActivity() const {
if (m_networkState == kNetworkLoading)
return true;
- // When playing or if playback may continue, timeupdate events may be fired.
- if (couldPlayIfEnoughData())
- return true;
+ {
+ // Disable potential updating of playback position, as that will
+ // require v8 allocations; not allowed while GCing
+ // (hasPendingActivity() is called during a v8 GC.)
+ DisablePlaybackPositionUpdateScope scope(
haraken 2016/11/16 06:47:26 Can we use AutoReset?
sof 2016/11/16 08:11:16 Thanks, I'd forgotten about TemporaryChange<> / Au
+ &m_officialPlaybackPositionNeedsUpdate);
+
+ // When playing or if playback may continue, timeupdate events may be fired.
+ if (couldPlayIfEnoughData())
+ return true;
+ }
// When the seek finishes timeupdate and seeked events will be fired.
if (m_seeking)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698