Bug 235981 - Copy PDF.js in WebCore.framework bundle at build-time
Summary: Copy PDF.js in WebCore.framework bundle at build-time
Status: RESOLVED DUPLICATE of bug 241117
Alias: None
Product: WebKit
Classification: Unclassified
Component: PDF (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Elliott Williams
URL:
Keywords: InRadar
Depends on: 242263 237844 241117
Blocks: 235969
  Show dependency treegraph
 
Reported: 2022-02-01 15:36 PST by Tim Nguyen (:ntim)
Modified: 2022-07-01 15:07 PDT (History)
5 users (show)

See Also:


Attachments
Patch (2.96 KB, patch)
2022-02-11 02:55 PST, Tim Nguyen (:ntim)
no flags Details | Formatted Diff | Diff
Patch (4.82 KB, patch)
2022-02-15 11:24 PST, Tim Nguyen (:ntim)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Nguyen (:ntim) 2022-02-01 15:36:30 PST
We should:

- get the downloaded version of PDF.js from https://mozilla.github.io/pdf.js/getting_started/#download (the Prebuilt one)
- include it somewhere in Source/WebCore
- create a script that copies it into the WebCore bundle
- run that script during the build
Comment 1 Radar WebKit Bug Importer 2022-02-01 15:36:43 PST
<rdar://problem/88352142>
Comment 2 Tim Nguyen (:ntim) 2022-02-11 02:55:23 PST
Created attachment 451664 [details]
Patch
Comment 3 EWS 2022-02-11 04:06:54 PST
Committed r289616 (247127@main): <https://commits.webkit.org/247127@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 451664 [details].
Comment 4 Tim Nguyen (:ntim) 2022-02-11 10:25:25 PST
Reverted this in r289637 since this broke production builds:

```
    /bin/sh -c /System/Volumes/Data/otmp/od.xLjbWx/lw.JIlSYt/sandbox-0/OBJROOT/WebCore.build/WebCore.build/Script-49AA6B1727B6755F000B0F64.sh
rsync: link_stat "/System/Volumes/Data/otmp/od.xLjbWx/lw.JIlSYt/sandbox-0/WebCore/Source/WebCore/../ThirdParty/pdfjs/." failed: No such file or directory (2)
rsync error: some files could not be transferred (code 23) at /System/Volumes/Data/SWE/macOS/BuildRoots/6b362bc7f6/Library/Caches/com.apple.xbs/Sources/rsync/rsync-55/rsync/main.c(996) [sender=2.6.9]
/System/Volumes/Data/otmp/od.xLjbWx/lw.JIlSYt/sandbox-0/OBJROOT/WebCore.build/WebCore.build/Script-49AA6B1727B6755F000B0F64.sh: line 9: cd: /System/Volumes/Data/otmp/od.xLjbWx/lw.JIlSYt/sandbox-0/WebCore/Source/WebCore/../ThirdParty/pdfjs: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code
```
Comment 5 Elliott Williams 2022-02-11 10:51:44 PST
Comment on attachment 451664 [details]
Patch

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

> Source/WebCore/WebCore.xcodeproj/project.pbxproj:38406
> +		49AA6B1727B6755F000B0F64 /* Copy PDF.js Resources */ = {
> +			isa = PBXShellScriptBuildPhase;
> +			buildActionMask = 2147483647;
> +			files = (
> +			);
> +			inputFileListPaths = (
> +			);
> +			inputPaths = (
> +			);
> +			name = "Copy PDF.js Resources";
> +			outputFileListPaths = (
> +			);
> +			outputPaths = (
> +			);
> +			runOnlyForDeploymentPostprocessing = 0;
> +			shellPath = /bin/sh;
> +			shellScript = "SRC_DIR=\"$SRCROOT/../ThirdParty/pdfjs\"\nDST_DIR=\"$BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/pdfjs\"\n\nmkdir -p \"$DST_DIR\"\n\nrsync -aq --exclude \".svn\" --exclude \".DS_Store\" \"$SRC_DIR/\" \"$DST_DIR/\"\n\ncd \"$SRC_DIR\"\n";
> +		};

I think it would be preferable to add `pdfjs/` to the xcodeproj as a folder reference, and use a Copy Files phase to copy it over. This gives Xcode's build system more dependency information about what's being copied, is marginally faster, and might help with the production build problems you're seeing.
Comment 6 Tim Nguyen (:ntim) 2022-02-15 11:24:46 PST
Created attachment 452064 [details]
Patch
Comment 7 Alexey Proskuryakov 2022-02-15 11:27:31 PST
Comment on attachment 452064 [details]
Patch

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

> Source/WebCore/Makefile:5
> +	mkdir -p $@

Do we need to quote this, or anything else, in case of spaces in the path?
Comment 8 EWS 2022-02-15 13:52:30 PST
Committed r289850 (247292@main): <https://commits.webkit.org/247292@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 452064 [details].
Comment 9 Tim Nguyen (:ntim) 2022-03-14 11:33:27 PDT
We're reverting this in bug 237844, since this causes a significant size increase in the bundle.

This patch can be re-landed once work on PDF.js resumes along with bundle size optimization.
Comment 10 Tim Nguyen (:ntim) 2022-03-14 11:35:42 PDT
(This needs a rebase fwiw)
Comment 11 Tim Nguyen (:ntim) 2022-03-14 11:36:43 PDT
To replicate the changes in Source/WebCore/WebCore.xcodeproj/project.pbxproj, add a folder reference to Source/ThirdParty/pdfjs in the WebCore/Resources folder in the file tree.
Comment 12 Tim Nguyen (:ntim) 2022-03-17 12:51:53 PDT
Worth noting that Igalia added a build option in bug 238023, probably worth using that for file size concerns.
Comment 13 Tim Nguyen (:ntim) 2022-07-01 15:07:27 PDT

*** This bug has been marked as a duplicate of bug 241117 ***