Bug 157162 - Web Inspector: FormatterWorker fails to find "External/Esprima.js" in Production builds
Summary: Web Inspector: FormatterWorker fails to find "External/Esprima.js" in Product...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
: 157223 157343 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-04-28 20:19 PDT by Joseph Pecoraro
Modified: 2016-05-04 16:04 PDT (History)
10 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (4.62 KB, patch)
2016-04-28 21:09 PDT, Joseph Pecoraro
joepeck: commit-queue-
Details | Formatted Diff | Diff
[PATCH] Proposed Fix (4.68 KB, patch)
2016-04-28 21:16 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2016-04-28 20:19:29 PDT
* SUMMARY
FormatterWorker fails to find "External/Esprima.js" in Production builds.

This affects Safari Technology Preview Release 3 and Nightlies.

* STEPS TO REPRODUCE
1. Open Inspector on this page
2. Try to open any Script with minified contents
  => Infinite loading indicator

* ERROR
[Error] Failed to load resource: The requested URL was not found on this server. (esprima.js, line 0)
URL in this case being: file:///Applications/Safari%20Technology%20Preview.app/Contents/Frameworks/WebInspectorUI.framework/Resources/External/Esprima/esprima.js

Bad path:
WebInspectorUI.framework/Resources/External/Esprima.js

The actual path ends up be:
WebInspectorUI.framework/Resources/Esprima.js

* NOTES
Source/WebInspectorUI/UserInterface/Workers/Formatter/FormatterWorker.js does:
> importScripts(...[
>     "../../External/Esprima/esprima.js",
>     "FormatterUtilities.js",
>     "FormatterContentBuilder.js",
>     "ESTreeWalker.js",
>     "EsprimaFormatter.js",
> ]);

So apparently our optimization pass doesn't keep the External directory.
Comment 1 Radar WebKit Bug Importer 2016-04-28 20:22:45 PDT
<rdar://problem/25996556>
Comment 2 Joseph Pecoraro 2016-04-28 21:09:57 PDT
Created attachment 277670 [details]
[PATCH] Proposed Fix
Comment 3 Joseph Pecoraro 2016-04-28 21:11:21 PDT
Here is an example of the script producing a warning and working correctly. It modifies the files in place, so you can test on the UserInterface directory.

# Comment out the line that does the replace.

    shell> perl ./Scripts/fix-worker-imports-for-optimized-builds.pl --input-directory ./UserInterface/Workers
    ERROR: Workers/Formatter/FormatterWorker.js: Unhandled External importScript in Worker script on line 27:     "../../External/Esprima/esprima.js",

    shell> echo $?
    1

# Revert the script back to expected

    shell> perl ./Scripts/fix-worker-imports-for-optimized-builds.pl --input-directory ./UserInterface/Workers

    shell> echo $?
    0

    shell> git diff .
    diff --git a/Source/WebInspectorUI/UserInterface/Workers/Formatter/FormatterWorker.js b/Source/WebInspectorUI/UserInterface/Workers/Formatter/FormatterWorker.js
    index 4f9067b..5811361 100644
    --- a/Source/WebInspectorUI/UserInterface/Workers/Formatter/FormatterWorker.js
    +++ b/Source/WebInspectorUI/UserInterface/Workers/Formatter/FormatterWorker.js
    @@ -24,7 +24,7 @@
      */
 
     importScripts(...[
    -    "../../External/Esprima/esprima.js",
    +    "../../Esprima.js",
         "FormatterUtilities.js",
         "FormatterContentBuilder.js",
         "ESTreeWalker.js",
Comment 4 Joseph Pecoraro 2016-04-28 21:15:16 PDT
Comment on attachment 277670 [details]
[PATCH] Proposed Fix

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

> Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl:250
> +    system(File::Spec->catfile($scriptsRoot, 'fix-worker-imports-for-optimized-builds.pl'), '--input-directory', $workersDir);

This should: and die "Reason"; so that `make` itself fails the build if fix-worker-imports returns with a bad exit code
Comment 5 Joseph Pecoraro 2016-04-28 21:16:58 PDT
Created attachment 277671 [details]
[PATCH] Proposed Fix
Comment 6 Joseph Pecoraro 2016-04-28 21:19:18 PDT
With the "and die" the build will actually fail now if this script fails.

    PhaseScriptExecution Copy\ User\ Interface\ Resources /Build/WebInspectorUI.build/Release/WebInspectorUI.build/Script-1C60FF1214E6D9AF006CD77D.sh
        cd /Code/safari/OpenSource/Source/WebInspectorUI
        export ACTION=build
        export ALTERNATE_GROUP=staff
        ....
        /bin/sh -c /Build/WebInspectorUI.build/Release/WebInspectorUI.build/Script-1C60FF1214E6D9AF006CD77D.sh
    ERROR: Workers/Formatter/FormatterWorker.js: Unhandled External importScript in Worker script on line 27:     "../../External/Esprima/esprima.js",
    Failed to update Worker imports for optimized builds. at /Code/safari/OpenSource/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl line 250.
    Command /bin/sh failed with exit code 1

That is important, otherwise these issues could go unnoticed!
Comment 7 WebKit Commit Bot 2016-04-28 22:23:17 PDT
Comment on attachment 277671 [details]
[PATCH] Proposed Fix

Clearing flags on attachment: 277671

Committed r200229: <http://trac.webkit.org/changeset/200229>
Comment 8 WebKit Commit Bot 2016-04-28 22:23:23 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Joseph Pecoraro 2016-04-29 19:14:54 PDT
*** Bug 157223 has been marked as a duplicate of this bug. ***
Comment 10 Timothy Hatcher 2016-05-04 16:04:37 PDT
*** Bug 157343 has been marked as a duplicate of this bug. ***