Bug 141225 - Web Inspector: REGRESSION: Inline SourceMap resources show empty content when opened.
Summary: Web Inspector: REGRESSION: Inline SourceMap resources show empty content when...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-02-03 17:43 PST by Jonathan Wells
Modified: 2022-03-01 02:48 PST (History)
7 users (show)

See Also:


Attachments
[PATCH] Attempted fix (4.92 KB, patch)
2015-02-03 17:59 PST, Jonathan Wells
no flags Details | Formatted Diff | Diff
[SCREENSHOT] patched. (240.93 KB, image/png)
2015-02-03 18:00 PST, Jonathan Wells
no flags Details
[SCREENSHOT] broken behavior. (2.01 MB, image/tiff)
2015-02-03 18:01 PST, Jonathan Wells
no flags Details
[PATCH] Fix based on feedback. (5.05 KB, patch)
2015-02-04 15:35 PST, Jonathan Wells
no flags Details | Formatted Diff | Diff
[PATCH] Fix with further feedback. (7.19 KB, patch)
2015-02-04 20:37 PST, Jonathan Wells
timothy: review+
Details | Formatted Diff | Diff
[SCREENSHOT] patched NetworkAgent error. (210.51 KB, image/png)
2015-02-04 20:39 PST, Jonathan Wells
no flags Details
[SCREENSHOT] patched NetworkAgent error assertion. (181.47 KB, image/png)
2015-02-04 20:39 PST, Jonathan Wells
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wells 2015-02-03 17:43:39 PST
Regression from http://trac.webkit.org/changeset/177791. Happens with base64 encoded SourceMaps only.
Comment 1 Radar WebKit Bug Importer 2015-02-03 17:43:55 PST
<rdar://problem/19709617>
Comment 2 Jonathan Wells 2015-02-03 17:44:25 PST
<rdar://problem/19510507>
Comment 3 Jonathan Wells 2015-02-03 17:59:27 PST
Created attachment 246000 [details]
[PATCH] Attempted fix

See screenshots for fix result.
Comment 4 Jonathan Wells 2015-02-03 18:00:19 PST
Created attachment 246001 [details]
[SCREENSHOT] patched.
Comment 5 Jonathan Wells 2015-02-03 18:01:25 PST
Created attachment 246003 [details]
[SCREENSHOT] broken behavior.
Comment 6 Jonathan Wells 2015-02-03 18:02:36 PST
<rdar://problem/19566353>
Comment 7 Joseph Pecoraro 2015-02-03 18:11:48 PST
Comment on attachment 246000 [details]
[PATCH] Attempted fix

View in context: https://bugs.webkit.org/attachment.cgi?id=246000&action=review

> Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js:106
> +        function sourceMapResourceLoadError(error)
>          {
> +            // There was an error calling NetworkAgent.loadResource.
> +            throw new Error(error);
> +        }

I don't think we want to throw an exception in our code when this happens. Doesn't this break iOS 6 and iOS 7 inspection of a page with Source Map contents?

> Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js:113
> +            var error = parameters.error;
> +            var content = parameters.content;
> +            var mimeType = parameters.mimeType;
> +            var statusCode = parameters.status;

This could be written more simply:

  var {error, content, mimeType, statusCode} = parameters;
Comment 8 Jonathan Wells 2015-02-03 19:27:42 PST
Comment on attachment 246000 [details]
[PATCH] Attempted fix

View in context: https://bugs.webkit.org/attachment.cgi?id=246000&action=review

>> Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js:106
>> +        }
> 
> I don't think we want to throw an exception in our code when this happens. Doesn't this break iOS 6 and iOS 7 inspection of a page with Source Map contents?

Why would that happen?

>> Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js:113
>> +            var statusCode = parameters.status;
> 
> This could be written more simply:
> 
>   var {error, content, mimeType, statusCode} = parameters;

Good call!
Comment 9 Jonathan Wells 2015-02-04 14:15:28 PST
Comment on attachment 246000 [details]
[PATCH] Attempted fix

View in context: https://bugs.webkit.org/attachment.cgi?id=246000&action=review

>>> Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js:106
>>> +        }
>> 
>> I don't think we want to throw an exception in our code when this happens. Doesn't this break iOS 6 and iOS 7 inspection of a page with Source Map contents?
> 
> Why would that happen?

So it turns out iOS 6 and iOS 7 don't even register that there is a source map present, even with inline source maps. The SourceMapResource constructor is never called.
Comment 10 Joseph Pecoraro 2015-02-04 14:44:18 PST
Comment on attachment 246000 [details]
[PATCH] Attempted fix

View in context: https://bugs.webkit.org/attachment.cgi?id=246000&action=review

>>>> Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js:106
>>>> +        }
>>> 
>>> I don't think we want to throw an exception in our code when this happens. Doesn't this break iOS 6 and iOS 7 inspection of a page with Source Map contents?
>> 
>> Why would that happen?
> 
> So it turns out iOS 6 and iOS 7 don't even register that there is a source map present, even with inline source maps. The SourceMapResource constructor is never called.

Yeah, it looks like previously in SourceMapManager._loadAndParseSourceMap we would have done nothing if !NetworkAgent.loadResource. We should probably update that to better handle data URLs.
Comment 11 Jonathan Wells 2015-02-04 15:35:37 PST
Created attachment 246060 [details]
[PATCH] Fix based on feedback.
Comment 12 Timothy Hatcher 2015-02-04 18:58:59 PST
Comment on attachment 246060 [details]
[PATCH] Fix based on feedback.

View in context: https://bugs.webkit.org/attachment.cgi?id=246060&action=review

> Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js:107
> +            // There was an error calling NetworkAgent.loadResource.
> +            // FIXME: https://bugs.webkit.org/show_bug.cgi?id=141266 needs to change this condition to be compatible
> +            // with legacy iOS versions. As it is those versions would hit this code path and stop execution.
> +            throw new Error(error);

I'm still not sure why this needs to throw. We don't want to break the UI.

> Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js:133
> +            sourceMapResourceLoadError.call(this, "No NetworkAgent.loadResource");

Can we just remove this call or use sourceMapResourceNotAvailable with empty data and a 500 status code or something?
Comment 13 Jonathan Wells 2015-02-04 19:06:10 PST
Comment on attachment 246060 [details]
[PATCH] Fix based on feedback.

View in context: https://bugs.webkit.org/attachment.cgi?id=246060&action=review

>> Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js:107
>> +            throw new Error(error);
> 
> I'm still not sure why this needs to throw. We don't want to break the UI.

This should have been console.error().

>> Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js:133
>> +            sourceMapResourceLoadError.call(this, "No NetworkAgent.loadResource");
> 
> Can we just remove this call or use sourceMapResourceNotAvailable with empty data and a 500 status code or something?

Sure, maybe with a console.assert() along with it.
Comment 14 Jonathan Wells 2015-02-04 20:37:46 PST
Created attachment 246078 [details]
[PATCH] Fix with further feedback.

This will no longer halt execution if NetworkAgent.loadResource is unavailable or fails to work. Also WebInspector.SourceCode.prototype._processContent wasn't handling error messages correctly which has been fixed. The result can bee seen in screenshots being attached now.
Comment 15 Jonathan Wells 2015-02-04 20:39:17 PST
Created attachment 246079 [details]
[SCREENSHOT] patched NetworkAgent error.

Shows what happens if the NetworkAgent should be unavailable or return an error state.
Comment 16 Jonathan Wells 2015-02-04 20:39:48 PST
Created attachment 246080 [details]
[SCREENSHOT] patched NetworkAgent error assertion.

Assertion failing when NetworkAgent is missing (inspecting the inspector).
Comment 17 Timothy Hatcher 2015-02-05 09:13:33 PST
Comment on attachment 246078 [details]
[PATCH] Fix with further feedback.

View in context: https://bugs.webkit.org/attachment.cgi?id=246078&action=review

> Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js:106
> +        function sourceMapResourceLoadError(error)
>          {
> +            // There was an error calling NetworkAgent.loadResource.
> +            console.error(error);
> +        }

You don't use sourceMapResourceLoadError since you added the console.assert. Should remove.
Comment 18 Jonathan Wells 2015-02-05 12:39:02 PST
Comment on attachment 246078 [details]
[PATCH] Fix with further feedback.

View in context: https://bugs.webkit.org/attachment.cgi?id=246078&action=review

>> Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js:106
>> +        }
> 
> You don't use sourceMapResourceLoadError since you added the console.assert. Should remove.

It could if NetworkAgent.requestContent has an unexpected failure. See line 143 of the same file. However I suppose this could also just call sourceMapResourceNotAvailable.
Comment 19 Timothy Hatcher 2015-02-05 13:01:14 PST
Comment on attachment 246078 [details]
[PATCH] Fix with further feedback.

View in context: https://bugs.webkit.org/attachment.cgi?id=246078&action=review

>>> Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js:106
>>> +        }
>> 
>> You don't use sourceMapResourceLoadError since you added the console.assert. Should remove.
> 
> It could if NetworkAgent.requestContent has an unexpected failure. See line 143 of the same file. However I suppose this could also just call sourceMapResourceNotAvailable.

Oh, I see. It probably would be best to call sourceMapResourceNotAvailable so the UI reflects the error. Otherwise, it will likely show a spinner indefinitely?
Comment 20 Jonathan Wells 2015-02-05 14:47:57 PST
Committed r179713: <http://trac.webkit.org/changeset/179713>