- Revision
- 113937
- Author
- [email protected]
- Date
- 2012-04-11 19:10:26 -0700 (Wed, 11 Apr 2012)
Log Message
[BlackBerry] MMRPlayer will hang webkit thread when retrieving media metadata
https://bugs.webkit.org/show_bug.cgi?id=80978
Patch by Jonathan Dong <[email protected]> on 2012-04-11
Reviewed by Rob Buis.
Source/WebCore:
RIM PR: 143471
Implemented the interface function onWaitMetadataNotified()
which starts a timer to wait for the metadata retrieving to
finish, and pops up a dialog to notify the user what to do
if there still is no metadata when the timer fires.
This patch also contributed by Max Feil <[email protected]>.
Internally reviewed by Max Feil.
Test: http/tests/media/video-throttled-load-metadata.html
* platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
(WebCore::MediaPlayerPrivate::MediaPlayerPrivate):
(WebCore):
(WebCore::MediaPlayerPrivate::onWaitMetadataNotified):
(WebCore::MediaPlayerPrivate::waitMetadataTimerFired):
* platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:
(MediaPlayerPrivate):
LayoutTests:
RIM PR: 143471
Added a layout test which simulates a slow network, and starts a web worker
thread to write a log message when retrieving media metadata to see if the
webkit thread is blocked by media retrieving thread.
* http/tests/media/video-throttled-load-metadata-expected.txt: Added.
* http/tests/media/video-throttled-load-metadata-worker.js: Added.
* http/tests/media/video-throttled-load-metadata.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (113936 => 113937)
--- trunk/LayoutTests/ChangeLog 2012-04-12 01:55:35 UTC (rev 113936)
+++ trunk/LayoutTests/ChangeLog 2012-04-12 02:10:26 UTC (rev 113937)
@@ -1,3 +1,19 @@
+2012-04-11 Jonathan Dong <[email protected]>
+
+ [BlackBerry] MMRPlayer will hang webkit thread when retrieving media metadata
+ https://bugs.webkit.org/show_bug.cgi?id=80978
+
+ Reviewed by Rob Buis.
+
+ RIM PR: 143471
+ Added a layout test which simulates a slow network, and starts a web worker
+ thread to write a log message when retrieving media metadata to see if the
+ webkit thread is blocked by media retrieving thread.
+
+ * http/tests/media/video-throttled-load-metadata-expected.txt: Added.
+ * http/tests/media/video-throttled-load-metadata-worker.js: Added.
+ * http/tests/media/video-throttled-load-metadata.html: Added.
+
2012-04-11 Jer Noble <[email protected]>
Layout Test webaudio/* is flaky
Added: trunk/LayoutTests/http/tests/media/video-throttled-load-metadata-expected.txt (0 => 113937)
--- trunk/LayoutTests/http/tests/media/video-throttled-load-metadata-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/media/video-throttled-load-metadata-expected.txt 2012-04-12 02:10:26 UTC (rev 113937)
@@ -0,0 +1,9 @@
+This test case simulates a slow network, and starts a web worker thread to write a log message when retrieving media metadata to see if the webkit thread is blocked by media retrieving thread.
+This test case is for https://bugs.webkit.org/show_bug.cgi?id=80978
+
+EXPECTED (video.error == 'null') OK
+Message from worker thread OK
+EVENT(loadedmetadata)
+loaded metadata of media file OK
+END OF TEST
+
Added: trunk/LayoutTests/http/tests/media/video-throttled-load-metadata-worker.js (0 => 113937)
--- trunk/LayoutTests/http/tests/media/video-throttled-load-metadata-worker.js (rev 0)
+++ trunk/LayoutTests/http/tests/media/video-throttled-load-metadata-worker.js 2012-04-12 02:10:26 UTC (rev 113937)
@@ -0,0 +1,2 @@
+postMessage("Message from worker thread");
+
Added: trunk/LayoutTests/http/tests/media/video-throttled-load-metadata.html (0 => 113937)
--- trunk/LayoutTests/http/tests/media/video-throttled-load-metadata.html (rev 0)
+++ trunk/LayoutTests/http/tests/media/video-throttled-load-metadata.html 2012-04-12 02:10:26 UTC (rev 113937)
@@ -0,0 +1,46 @@
+<html>
+<head>
+ <title>throttled loading metadata</title>
+ <script src=""
+ <script src=""
+ <script>
+ function loadedmetadata(e)
+ {
+ logResult(true, "loaded metadata of media file");
+ endTest();
+ }
+
+ function error(e)
+ {
+ logResult(false, "failed to load media file");
+ endTest();
+ }
+
+ function start()
+ {
+ findMediaElement();
+
+ waitForEvent('loadedmetadata', loadedmetadata);
+ waitForEvent("error", error);
+ testExpected("video.error", null);
+
+ var worker = new Worker("video-throttled-load-metadata-worker.js");
+ worker._onmessage_ = function (event) {
+ logResult(true, event.data);
+ }
+ var movie = findMediaFile("video", "resources/test");
+ var type = mimeTypeForExtension(movie.split('.').pop());
+ video.src = "" + movie + "&throttle=400&type=" + type;
+ video.load();
+ }
+ </script>
+</head>
+<body _onload_="start()">
+<video id="video"></video>
+<p>
+This test case simulates a slow network, and starts a web worker thread to write a log message
+when retrieving media metadata to see if the webkit thread is blocked by media retrieving thread.<br>
+This test case is for <a href=""
+</p>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (113936 => 113937)
--- trunk/Source/WebCore/ChangeLog 2012-04-12 01:55:35 UTC (rev 113936)
+++ trunk/Source/WebCore/ChangeLog 2012-04-12 02:10:26 UTC (rev 113937)
@@ -1,3 +1,29 @@
+2012-04-11 Jonathan Dong <[email protected]>
+
+ [BlackBerry] MMRPlayer will hang webkit thread when retrieving media metadata
+ https://bugs.webkit.org/show_bug.cgi?id=80978
+
+ Reviewed by Rob Buis.
+
+ RIM PR: 143471
+ Implemented the interface function onWaitMetadataNotified()
+ which starts a timer to wait for the metadata retrieving to
+ finish, and pops up a dialog to notify the user what to do
+ if there still is no metadata when the timer fires.
+
+ This patch also contributed by Max Feil <[email protected]>.
+ Internally reviewed by Max Feil.
+
+ Test: http/tests/media/video-throttled-load-metadata.html
+
+ * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp:
+ (WebCore::MediaPlayerPrivate::MediaPlayerPrivate):
+ (WebCore):
+ (WebCore::MediaPlayerPrivate::onWaitMetadataNotified):
+ (WebCore::MediaPlayerPrivate::waitMetadataTimerFired):
+ * platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h:
+ (MediaPlayerPrivate):
+
2012-04-11 Jer Noble <[email protected]>
Layout Test webaudio/* is flaky
Modified: trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp (113936 => 113937)
--- trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp 2012-04-12 01:55:35 UTC (rev 113936)
+++ trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.cpp 2012-04-12 02:10:26 UTC (rev 113937)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2011, 2012 Research In Motion Limited. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -112,6 +112,8 @@
#endif
, m_userDrivenSeekTimer(this, &MediaPlayerPrivate::userDrivenSeekTimerFired)
, m_lastSeekTime(0)
+ , m_waitMetadataTimer(this, &MediaPlayerPrivate::waitMetadataTimerFired)
+ , m_waitMetadataPopDialogCounter(0)
{
}
@@ -601,6 +603,50 @@
element->pause();
}
+static const int popupDialogInterval = 10;
+static const double checkMetadataReadyInterval = 0.5;
+void MediaPlayerPrivate::onWaitMetadataNotified(bool hasFinished, int timeWaited)
+{
+ if (!hasFinished) {
+ if (!m_waitMetadataTimer.isActive()) {
+ // Make sure to popup dialog every 10 seconds after metadata start to load.
+ // This should be set only once at the first time when user press the play button.
+ m_waitMetadataPopDialogCounter = static_cast<int>(timeWaited / checkMetadataReadyInterval);
+ m_waitMetadataTimer.startOneShot(checkMetadataReadyInterval);
+ }
+ } else if (m_waitMetadataTimer.isActive()) {
+ m_waitMetadataTimer.stop();
+ m_waitMetadataPopDialogCounter = 0;
+ }
+}
+
+void MediaPlayerPrivate::waitMetadataTimerFired(Timer<MediaPlayerPrivate>*)
+{
+ if (m_platformPlayer->isMetadataReady()) {
+ m_platformPlayer->playWithMetadataReady();
+ m_waitMetadataPopDialogCounter = 0;
+ return;
+ }
+
+ static const int hitTimeToPopupDialog = static_cast<int>(popupDialogInterval / checkMetadataReadyInterval);
+ m_waitMetadataPopDialogCounter++;
+ if (m_waitMetadataPopDialogCounter < hitTimeToPopupDialog) {
+ m_waitMetadataTimer.startOneShot(checkMetadataReadyInterval);
+ return;
+ }
+ m_waitMetadataPopDialogCounter = 0;
+
+ int wait = showErrorDialog(MMRPlayer::MediaMetaDataTimeoutError);
+ if (!wait)
+ onPauseNotified();
+ else {
+ if (m_platformPlayer->isMetadataReady())
+ m_platformPlayer->playWithMetadataReady();
+ else
+ m_waitMetadataTimer.startOneShot(checkMetadataReadyInterval);
+ }
+}
+
#if USE(ACCELERATED_COMPOSITING)
void MediaPlayerPrivate::onBuffering(bool flag)
{
Modified: trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h (113936 => 113937)
--- trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h 2012-04-12 01:55:35 UTC (rev 113936)
+++ trunk/Source/WebCore/platform/graphics/blackberry/MediaPlayerPrivateBlackBerry.h 2012-04-12 02:10:26 UTC (rev 113937)
@@ -126,6 +126,7 @@
virtual void onSizeChanged();
virtual void onPlayNotified();
virtual void onPauseNotified();
+ virtual void onWaitMetadataNotified(bool hasFinished, int timeWaited);
#if USE(ACCELERATED_COMPOSITING)
virtual void onBuffering(bool);
#endif
@@ -161,6 +162,9 @@
void userDrivenSeekTimerFired(Timer<MediaPlayerPrivate>*);
Timer<MediaPlayerPrivate> m_userDrivenSeekTimer;
float m_lastSeekTime;
+ void waitMetadataTimerFired(Timer<MediaPlayerPrivate>*);
+ Timer<MediaPlayerPrivate> m_waitMetadataTimer;
+ int m_waitMetadataPopDialogCounter;
};
} // namespace WebCore