Changeset 218603 in webkit
- Timestamp:
- Jun 20, 2017 11:35:31 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r218600 r218603 1 2017-06-20 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: add console messages for WebGL shader compile and program link errors/warnings 4 https://bugs.webkit.org/show_bug.cgi?id=143236 5 <rdar://problem/20352149> 6 7 Reviewed by Dean Jackson. 8 9 * fast/canvas/webgl/fragment-shader-assertion.html: 10 * fast/canvas/webgl/shader-compile-logging-expected.txt: Added. 11 * fast/canvas/webgl/shader-compile-logging.html: Added. 12 1 13 2017-06-19 Antoine Quint <graouts@apple.com> 2 14 -
trunk/LayoutTests/fast/canvas/webgl/fragment-shader-assertion.html
r199340 r218603 4 4 if (window.testRunner) 5 5 testRunner.dumpAsText(); 6 7 if (window.internals) 8 window.internals.settings.setWebGLErrorsToConsoleEnabled(false); 6 9 7 10 function runTest() { -
trunk/Source/WebCore/ChangeLog
r218602 r218603 1 2017-06-20 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: add console messages for WebGL shader compile and program link errors/warnings 4 https://bugs.webkit.org/show_bug.cgi?id=143236 5 <rdar://problem/20352149> 6 7 Reviewed by Dean Jackson. 8 9 Test: fast/canvas/webgl/shader-compile-logging.html 10 11 * html/canvas/WebGLRenderingContextBase.h: 12 * html/canvas/WebGLRenderingContextBase.cpp: 13 (WebCore::WebGLRenderingContextBase::checkFramebufferStatus): 14 (WebCore::WebGLRenderingContextBase::compileShader): 15 (WebCore::WebGLRenderingContextBase::recycleContext): 16 (WebCore::WebGLRenderingContextBase::checkTextureCompleteness): 17 (WebCore::WebGLRenderingContextBase::printToConsole): 18 (WebCore::WebGLRenderingContextBase::maybeRestoreContext): 19 (WebCore::WebGLRenderingContextBase::synthesizeGLError): 20 (WebCore::WebGLRenderingContextBase::printGLErrorToConsole): Deleted. 21 (WebCore::WebGLRenderingContextBase::printWarningToConsole): Deleted. 22 (WebCore::WebGLRenderingContextBase::printGLWarningToConsole): Deleted. 23 Unify console logging helper functions to all follow the same path. Additionally, errors 24 now generate stack traces. Shader compilation errors are now logged as well. 25 26 * dom/Document.h: 27 * dom/Document.cpp: 28 (WebCore::Document::addConsoleMessage): 29 * dom/ScriptExecutionContext.h: 30 (WebCore::ScriptExecutionContext::AddConsoleMessageTask::AddConsoleMessageTask): 31 * page/PageConsoleClient.h: 32 * page/PageConsoleClient.cpp: 33 (WebCore::PageConsoleClient::addMessage): 34 * workers/WorkerGlobalScope.h: 35 Add new path for logging to the console that accepts a ConsoleMessage. 36 1 37 2017-06-20 Saam Barati <sbarati@apple.com> 2 38 -
trunk/Source/WebCore/dom/Document.cpp
r218529 r218603 198 198 #include "XPathResult.h" 199 199 #include <ctime> 200 #include <inspector/ConsoleMessage.h> 200 201 #include <inspector/ScriptCallStack.h> 201 202 #include <wtf/CurrentTime.h> … … 5546 5547 } 5547 5548 5549 void Document::addConsoleMessage(std::unique_ptr<Inspector::ConsoleMessage>&& consoleMessage) 5550 { 5551 if (!isContextThread()) { 5552 postTask(AddConsoleMessageTask(WTFMove(consoleMessage))); 5553 return; 5554 } 5555 5556 if (Page* page = this->page()) 5557 page->console().addMessage(WTFMove(consoleMessage)); 5558 } 5559 5548 5560 void Document::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, unsigned long requestIdentifier) 5549 5561 { -
trunk/Source/WebCore/dom/Document.h
r218602 r218603 1260 1260 void removeDisabledFieldsetElement() { ASSERT(m_disabledFieldsetElementsCount); m_disabledFieldsetElementsCount--; } 1261 1261 1262 WEBCORE_EXPORT void addConsoleMessage(std::unique_ptr<Inspector::ConsoleMessage>&&) final; 1263 1264 // The following addConsoleMessage function is deprecated. 1265 // Callers should try to create the ConsoleMessage themselves. 1262 1266 WEBCORE_EXPORT void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) final; 1263 1267 … … 1407 1411 void derefScriptExecutionContext() final { deref(); } 1408 1412 1413 // The following addMessage function is deprecated. 1414 // Callers should try to create the ConsoleMessage themselves. 1409 1415 void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<Inspector::ScriptCallStack>&&, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0) final; 1410 1416 -
trunk/Source/WebCore/dom/ScriptExecutionContext.h
r218593 r218603 46 46 47 47 namespace Inspector { 48 class ConsoleMessage; 48 49 class ScriptCallStack; 49 50 } … … 98 99 void reportUnhandledPromiseRejection(JSC::ExecState&, JSC::JSPromise&, RefPtr<Inspector::ScriptCallStack>&&); 99 100 101 virtual void addConsoleMessage(std::unique_ptr<Inspector::ConsoleMessage>&&) = 0; 102 103 // The following addConsoleMessage functions are deprecated. 104 // Callers should try to create the ConsoleMessage themselves. 100 105 void addConsoleMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0); 101 106 virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) = 0; … … 224 229 class AddConsoleMessageTask : public Task { 225 230 public: 231 AddConsoleMessageTask(std::unique_ptr<Inspector::ConsoleMessage>&& consoleMessage) 232 : Task([&consoleMessage](ScriptExecutionContext& context) { 233 context.addConsoleMessage(WTFMove(consoleMessage)); 234 }) 235 { 236 } 237 226 238 AddConsoleMessageTask(MessageSource source, MessageLevel level, const String& message) 227 239 : Task([source, level, message = message.isolatedCopy()](ScriptExecutionContext& context) { … … 237 249 238 250 private: 251 // The following addMessage function is deprecated. 252 // Callers should try to create the ConsoleMessage themselves. 239 253 virtual void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<Inspector::ScriptCallStack>&&, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0) = 0; 240 254 virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, RefPtr<Inspector::ScriptCallStack>&&) = 0; -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
r217298 r218603 53 53 #include "ImageBuffer.h" 54 54 #include "ImageData.h" 55 #include "InspectorInstrumentation.h" 55 56 #include "IntSize.h" 57 #include "JSMainThreadExecState.h" 56 58 #include "Logging.h" 57 59 #include "MainFrame.h" … … 90 92 #include "WebGLTexture.h" 91 93 #include "WebGLUniformLocation.h" 92 94 #include <inspector/ConsoleMessage.h> 95 #include <inspector/ScriptCallStack.h> 96 #include <inspector/ScriptCallStackFactory.h> 93 97 #include <runtime/JSCInlines.h> 94 98 #include <runtime/TypedArrayInlines.h> … … 345 349 { 346 350 if (m_context->m_synthesizedErrorsToConsole) 347 m_context->print GLErrorToConsole(message);351 m_context->printToConsole(MessageLevel::Error, message); 348 352 } 349 353 virtual ~WebGLRenderingContextErrorMessageCallback() { } … … 1243 1247 GC3Denum result = m_framebufferBinding->checkStatus(&reason); 1244 1248 if (result != GraphicsContext3D::FRAMEBUFFER_COMPLETE) { 1245 printGLWarningToConsole("checkFramebufferStatus", reason); 1249 String str = "WebGL: checkFramebufferStatus:" + String(reason); 1250 printToConsole(MessageLevel::Warning, str); 1246 1251 return result; 1247 1252 } … … 1304 1309 m_context->getShaderiv(objectOrZero(shader), GraphicsContext3D::COMPILE_STATUS, &value); 1305 1310 shader->setValid(value); 1311 1312 if (m_synthesizedErrorsToConsole && !value) { 1313 Ref<Inspector::ScriptCallStack> stackTrace = Inspector::createScriptCallStack(JSMainThreadExecState::currentState(), Inspector::ScriptCallStack::maxCallStackSizeToCapture); 1314 1315 Vector<String> errors; 1316 getShaderInfoLog(shader).split("\n", errors); 1317 for (String& error : errors) 1318 canvas().document().addConsoleMessage(std::make_unique<Inspector::ConsoleMessage>(MessageSource::Rendering, MessageType::Log, MessageLevel::Error, "WebGL: " + error, stackTrace.copyRef())); 1319 } 1306 1320 } 1307 1321 … … 4573 4587 void WebGLRenderingContextBase::recycleContext() 4574 4588 { 4575 print WarningToConsole("There are too many active WebGL contexts on this page, the oldest context will be lost.");4589 printToConsole(MessageLevel::Error, "There are too many active WebGL contexts on this page, the oldest context will be lost."); 4576 4590 // Using SyntheticLostContext means the developer won't be able to force the restoration 4577 4591 // of the context by calling preventDefault() in a "webglcontextlost" event handler. … … 4830 4844 + " is not renderable. It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete'," 4831 4845 + " or it is a float/half-float type with linear filtering and without the relevant float/half-float linear extension enabled."); 4832 print GLWarningToConsole(functionName, msg.utf8().data());4846 printToConsole(MessageLevel::Error, "WebGL: " + String(functionName) + ": " + msg); 4833 4847 tex2D = m_blackTexture2D.get(); 4834 4848 texCubeMap = m_blackTextureCubeMap.get(); … … 5201 5215 } 5202 5216 5203 void WebGLRenderingContextBase::printGLErrorToConsole(const String& message) 5204 { 5217 void WebGLRenderingContextBase::printToConsole(MessageLevel level, const String& message) 5218 { 5219 if (!m_synthesizedErrorsToConsole || !m_numGLErrorsToConsoleAllowed) 5220 return; 5221 5222 std::unique_ptr<Inspector::ConsoleMessage> consoleMessage; 5223 5224 // Error messages can occur during function calls, so show stack traces for them. 5225 if (level == MessageLevel::Error) { 5226 Ref<Inspector::ScriptCallStack> stackTrace = Inspector::createScriptCallStack(JSMainThreadExecState::currentState(), Inspector::ScriptCallStack::maxCallStackSizeToCapture); 5227 consoleMessage = std::make_unique<Inspector::ConsoleMessage>(MessageSource::Rendering, MessageType::Log, level, message, WTFMove(stackTrace)); 5228 } else 5229 consoleMessage = std::make_unique<Inspector::ConsoleMessage>(MessageSource::Rendering, MessageType::Log, level, message); 5230 5231 canvas().document().addConsoleMessage(WTFMove(consoleMessage)); 5232 5233 --m_numGLErrorsToConsoleAllowed; 5205 5234 if (!m_numGLErrorsToConsoleAllowed) 5206 return; 5207 5208 --m_numGLErrorsToConsoleAllowed; 5209 printWarningToConsole(message); 5210 5211 if (!m_numGLErrorsToConsoleAllowed) 5212 printWarningToConsole("WebGL: too many errors, no more errors will be reported to the console for this context."); 5213 } 5214 5215 void WebGLRenderingContextBase::printWarningToConsole(const String& message) 5216 { 5217 canvas().document().addConsoleMessage(MessageSource::Rendering, MessageLevel::Warning, message); 5235 printToConsole(MessageLevel::Warning, "WebGL: too many errors, no more errors will be reported to the console for this context."); 5218 5236 } 5219 5237 … … 5596 5614 // The rendering context is not restored if this context was 5597 5615 // guilty of causing the graphics reset. 5598 print WarningToConsole("WARNING: WebGL content on the page caused the graphics card to reset; not restoring the context");5616 printToConsole(MessageLevel::Warning, "WARNING: WebGL content on the page caused the graphics card to reset; not restoring the context"); 5599 5617 return; 5600 5618 case Extensions3D::INNOCENT_CONTEXT_RESET_ARB: … … 5607 5625 // the content. Only if they say "yes" should we start 5608 5626 // attempting to restore the context. 5609 print WarningToConsole("WARNING: WebGL content on the page might have caused the graphics card to reset");5627 printToConsole(MessageLevel::Warning, "WARNING: WebGL content on the page might have caused the graphics card to reset"); 5610 5628 break; 5611 5629 } … … 5729 5747 { 5730 5748 if (m_synthesizedErrorsToConsole && display == DisplayInConsole) { 5731 String str = String("WebGL: ")+ GetErrorString(error) + ": " + String(functionName) + ": " + String(description);5732 printGLErrorToConsole(str);5749 String str = "WebGL: " + GetErrorString(error) + ": " + String(functionName) + ": " + String(description); 5750 printToConsole(MessageLevel::Error, str); 5733 5751 } 5734 5752 m_context->synthesizeGLError(error); 5735 }5736 5737 5738 void WebGLRenderingContextBase::printGLWarningToConsole(const char* functionName, const char* description)5739 {5740 if (m_synthesizedErrorsToConsole) {5741 String str = String("WebGL: ") + String(functionName) + ": " + String(description);5742 printGLErrorToConsole(str);5743 }5744 5753 } 5745 5754 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h
r217298 r218603 744 744 void texParameter(GC3Denum target, GC3Denum pname, GC3Dfloat parami, GC3Dint paramf, bool isFloat); 745 745 746 // Helper function to print GL errors to console. 747 void printGLErrorToConsole(const String&); 748 void printGLWarningToConsole(const char* function, const char* reason); 749 750 // Helper function to print warnings to console. Currently 751 // used only to warn about use of obsolete functions. 752 void printWarningToConsole(const String&); 746 // Helper function to print errors and warnings to console. 747 void printToConsole(MessageLevel, const String&); 753 748 754 749 // Helper function to validate input parameters for framebuffer functions. -
trunk/Source/WebCore/page/PageConsoleClient.cpp
r212448 r218603 106 106 } 107 107 108 void PageConsoleClient::addMessage(std::unique_ptr<Inspector::ConsoleMessage>&& consoleMessage) 109 { 110 if (consoleMessage->source() != MessageSource::CSS && !m_page.usesEphemeralSession()) { 111 m_page.chrome().client().addMessageToConsole(consoleMessage->source(), consoleMessage->level(), consoleMessage->message(), consoleMessage->line(), consoleMessage->column(), consoleMessage->url()); 112 113 if (m_page.settings().logsPageMessagesToSystemConsoleEnabled() || shouldPrintExceptions()) 114 ConsoleClient::printConsoleMessage(MessageSource::ConsoleAPI, MessageType::Log, consoleMessage->level(), consoleMessage->message(), consoleMessage->url(), consoleMessage->line(), consoleMessage->column()); 115 } 116 117 InspectorInstrumentation::addMessageToConsole(m_page, WTFMove(consoleMessage)); 118 } 119 108 120 void PageConsoleClient::addMessage(MessageSource source, MessageLevel level, const String& message, unsigned long requestIdentifier, Document* document) 109 121 { … … 133 145 message = std::make_unique<Inspector::ConsoleMessage>(source, MessageType::Log, level, messageText, suggestedURL, suggestedLineNumber, suggestedColumnNumber, state, requestIdentifier); 134 146 147 addMessage(WTFMove(message)); 148 } 149 150 151 void PageConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, Ref<Inspector::ScriptArguments>&& arguments) 152 { 153 String messageText; 154 bool gotMessage = arguments->getFirstArgumentAsString(messageText); 155 156 auto message = std::make_unique<Inspector::ConsoleMessage>(MessageSource::ConsoleAPI, type, level, messageText, arguments.copyRef(), exec); 157 135 158 String url = message->url(); 136 159 unsigned lineNumber = message->line(); … … 139 162 InspectorInstrumentation::addMessageToConsole(m_page, WTFMove(message)); 140 163 141 if (source == MessageSource::CSS)142 return;143 144 if (m_page.usesEphemeralSession())145 return;146 147 m_page.chrome().client().addMessageToConsole(source, level, messageText, lineNumber, columnNumber, url);148 149 if (!m_page.settings().logsPageMessagesToSystemConsoleEnabled() && !shouldPrintExceptions())150 return;151 152 ConsoleClient::printConsoleMessage(MessageSource::ConsoleAPI, MessageType::Log, level, messageText, url, lineNumber, columnNumber);153 }154 155 156 void PageConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, Ref<Inspector::ScriptArguments>&& arguments)157 {158 String messageText;159 bool gotMessage = arguments->getFirstArgumentAsString(messageText);160 161 auto message = std::make_unique<Inspector::ConsoleMessage>(MessageSource::ConsoleAPI, type, level, messageText, arguments.copyRef(), exec);162 163 String url = message->url();164 unsigned lineNumber = message->line();165 unsigned columnNumber = message->column();166 167 InspectorInstrumentation::addMessageToConsole(m_page, WTFMove(message));168 169 164 if (m_page.usesEphemeralSession()) 170 165 return; -
trunk/Source/WebCore/page/PageConsoleClient.h
r212448 r218603 33 33 #include <wtf/Forward.h> 34 34 35 namespace Inspector { 36 class ConsoleMessage; 37 } 38 35 39 namespace JSC { 36 40 class ExecState; … … 54 58 static void unmute(); 55 59 60 void addMessage(std::unique_ptr<Inspector::ConsoleMessage>&&); 61 62 // The following addMessage function are deprecated. 63 // Callers should try to create the ConsoleMessage themselves. 56 64 void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<Inspector::ScriptCallStack>&& = nullptr, JSC::ExecState* = nullptr, unsigned long requestIdentifier = 0); 57 65 void addMessage(MessageSource, MessageLevel, const String& message, Ref<Inspector::ScriptCallStack>&&); -
trunk/Source/WebCore/workers/WorkerGlobalScope.h
r218593 r218603 100 100 bool isClosing() { return m_closing; } 101 101 102 void addConsoleMessage(std::unique_ptr<Inspector::ConsoleMessage>&&) ;102 void addConsoleMessage(std::unique_ptr<Inspector::ConsoleMessage>&&) final; 103 103 104 104 Crypto& crypto(); … … 123 123 124 124 void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, RefPtr<Inspector::ScriptCallStack>&&) final; 125 126 // The following addMessage and addConsoleMessage functions are deprecated. 127 // Callers should try to create the ConsoleMessage themselves. 125 128 void addMessage(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<Inspector::ScriptCallStack>&&, JSC::ExecState*, unsigned long requestIdentifier) final; 126 129 void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier) final;
Note: See TracChangeset
for help on using the changeset viewer.