Title: [242641] trunk/Source/WebCore
- Revision
- 242641
- Author
- [email protected]
- Date
- 2019-03-08 09:02:16 -0800 (Fri, 08 Mar 2019)
Log Message
imported/w3c/web-platform-tests/FileAPI/reading-data-section/filereader_error.html is a flaky crash
https://bugs.webkit.org/show_bug.cgi?id=195441
<rdar://problem/43437394>
Reviewed by Alexey Proskuryakov.
FileReader is an ActiveDOMObject, which means that FileReader::stop() gets called when
its script execution context is about to get destroyed. FileReader::stop() sets m_state
to DONE. FileReader::abort() would schedule an asynchronous task and then ASSERT that
m_state is not DONE, which would hit if FileReader::stop() had been called in between
the task being scheduled and its execution. To address the issue, have the task abort
early if isContextStopped() returns true.
Also replace calls to setPendingActivity() / unsetPendingActivity() with a
PendingActivity data member as mismatched call to those can lead to leaks.
* fileapi/FileReader.cpp:
(WebCore::FileReader::canSuspendForDocumentSuspension const):
No reason not to suspend if there is no pending read.
(WebCore::FileReader::stop):
(WebCore::FileReader::readInternal):
(WebCore::FileReader::abort):
(WebCore::FileReader::didFinishLoading):
(WebCore::FileReader::didFail):
* fileapi/FileReader.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (242640 => 242641)
--- trunk/Source/WebCore/ChangeLog 2019-03-08 11:57:54 UTC (rev 242640)
+++ trunk/Source/WebCore/ChangeLog 2019-03-08 17:02:16 UTC (rev 242641)
@@ -1,3 +1,32 @@
+2019-03-08 Chris Dumez <[email protected]>
+
+ imported/w3c/web-platform-tests/FileAPI/reading-data-section/filereader_error.html is a flaky crash
+ https://bugs.webkit.org/show_bug.cgi?id=195441
+ <rdar://problem/43437394>
+
+ Reviewed by Alexey Proskuryakov.
+
+ FileReader is an ActiveDOMObject, which means that FileReader::stop() gets called when
+ its script execution context is about to get destroyed. FileReader::stop() sets m_state
+ to DONE. FileReader::abort() would schedule an asynchronous task and then ASSERT that
+ m_state is not DONE, which would hit if FileReader::stop() had been called in between
+ the task being scheduled and its execution. To address the issue, have the task abort
+ early if isContextStopped() returns true.
+
+ Also replace calls to setPendingActivity() / unsetPendingActivity() with a
+ PendingActivity data member as mismatched call to those can lead to leaks.
+
+ * fileapi/FileReader.cpp:
+ (WebCore::FileReader::canSuspendForDocumentSuspension const):
+ No reason not to suspend if there is no pending read.
+
+ (WebCore::FileReader::stop):
+ (WebCore::FileReader::readInternal):
+ (WebCore::FileReader::abort):
+ (WebCore::FileReader::didFinishLoading):
+ (WebCore::FileReader::didFail):
+ * fileapi/FileReader.h:
+
2019-03-08 Zan Dobersek <[email protected]>
GLContextEGL: desired EGL config should search for 8-bit components by default
Modified: trunk/Source/WebCore/fileapi/FileReader.cpp (242640 => 242641)
--- trunk/Source/WebCore/fileapi/FileReader.cpp 2019-03-08 11:57:54 UTC (rev 242640)
+++ trunk/Source/WebCore/fileapi/FileReader.cpp 2019-03-08 17:02:16 UTC (rev 242641)
@@ -64,8 +64,7 @@
bool FileReader::canSuspendForDocumentSuspension() const
{
- // FIXME: It is not currently possible to suspend a FileReader, so pages with FileReader can not go into page cache.
- return false;
+ return !hasPendingActivity();
}
const char* FileReader::activeDOMObjectName() const
@@ -80,6 +79,7 @@
m_loader = nullptr;
}
m_state = DONE;
+ m_loadingActivity = nullptr;
}
ExceptionOr<void> FileReader::readAsArrayBuffer(Blob* blob)
@@ -129,7 +129,7 @@
if (m_state == LOADING)
return Exception { InvalidStateError };
- setPendingActivity(*this);
+ m_loadingActivity = makePendingActivity(*this);
m_blob = &blob;
m_readType = type;
@@ -153,7 +153,10 @@
m_aborting = true;
// Schedule to have the abort done later since abort() might be called from the event handler and we do not want the resource loading code to be in the stack.
- scriptExecutionContext()->postTask([this] (ScriptExecutionContext&) {
+ scriptExecutionContext()->postTask([this, protectedThis = makeRef(*this)] (ScriptExecutionContext&) {
+ if (isContextStopped())
+ return;
+
ASSERT(m_state != DONE);
stop();
@@ -164,9 +167,6 @@
fireEvent(eventNames().errorEvent);
fireEvent(eventNames().abortEvent);
fireEvent(eventNames().loadendEvent);
-
- // All possible events have fired and we're done, no more pending activity.
- unsetPendingActivity(*this);
});
}
@@ -200,8 +200,7 @@
fireEvent(eventNames().loadEvent);
fireEvent(eventNames().loadendEvent);
- // All possible events have fired and we're done, no more pending activity.
- unsetPendingActivity(*this);
+ m_loadingActivity = nullptr;
}
void FileReader::didFail(int errorCode)
@@ -217,8 +216,7 @@
fireEvent(eventNames().errorEvent);
fireEvent(eventNames().loadendEvent);
- // All possible events have fired and we're done, no more pending activity.
- unsetPendingActivity(*this);
+ m_loadingActivity = nullptr;
}
void FileReader::fireEvent(const AtomicString& type)
Modified: trunk/Source/WebCore/fileapi/FileReader.h (242640 => 242641)
--- trunk/Source/WebCore/fileapi/FileReader.h 2019-03-08 11:57:54 UTC (rev 242640)
+++ trunk/Source/WebCore/fileapi/FileReader.h 2019-03-08 17:02:16 UTC (rev 242641)
@@ -102,6 +102,7 @@
std::unique_ptr<FileReaderLoader> m_loader;
RefPtr<FileError> m_error;
MonotonicTime m_lastProgressNotificationTime { MonotonicTime::nan() };
+ RefPtr<PendingActivity<FileReader>> m_loadingActivity;
};
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes