Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minified browser code in the packaged final app. #931

Merged
merged 1 commit into from
Mar 29, 2022

Conversation

kittaakos
Copy link
Contributor

  • Also switched to minified monaco code,
  • Removed dead code from the packager.

Signed-off-by: Akos Kitta kittaakos@gmail.com


Motivation

To improve the IDE load time using the minified browser code + minified monaco code.

Change description

  • From now on, the packager does not distinguish between release- and non-release builds; it always minifies the frontend code,
  • Removed dead code from the packager.

Other information

So this is a tiny improvement for the IDE load time, but I noticed, the bundled electron app does not contain minified code; it should.

Before the change load times:
Screen Shot 2022-03-28 at 14 11 26
Screen Shot 2022-03-28 at 14 10 52
Screen Shot 2022-03-28 at 14 10 27

After change load times:
Screen Shot 2022-03-28 at 15 08 37
Screen Shot 2022-03-28 at 15 08 20
Screen Shot 2022-03-28 at 15 08 56

Although you cannot notice significant app startup improvements 🤦 , the size of the loaded resources shows some improved numbers: it's down from 21.2 MB to 9.4 MB.

There are multiple ways to verify it.

  • Open the folder where the frontend lives. (It is cd /Applications/Arduino\ IDE.app/Contents/Resources/app/lib/ on macOS). Manually investigate the /vs/editor/editor.main.js file content. You can see the original monaco code in the latest RC build. With the proposed changes, all JS/CSS files are minified.
  • You can open the IDE, open the DevTools (with cmd+alt+i on macOS) > switch to the Network tab, and reload the window.

Reviewer checklist

  • PR addresses a single concern.
  • The PR has no duplicates (please search among the Pull Requests before creating one)
  • PR title and description are properly filled.
  • Docs have been added / updated (for bug fixes / features)

 - Also switched to minified `monaco` code,
 - Removed dead code from the packaged.

Signed-off-by: Akos Kitta <kittaakos@gmail.com>
@per1234 per1234 added the topic: code Related to content of the project itself label Mar 28, 2022
@@ -227,8 +227,7 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
'Installing dependencies'
);
exec(
`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} build${isElectronPublish ? ':publish' : ''
}`,
`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} build`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one @kittaakos. Just one thing: wouldn't it be better if we'd set isElectronPublish to true here?

That way we could still use yarn build to package the app in development mode when we need it. Does that make sense to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here?

Thanks for pointing out why it did not work 👍

package the app in development mode when we need it

Good point, but when do we need a packaged app for dev mode? I could not come up with a single use-case. I think isElectronPublish makes the packager logic confusing.
If we still want to support a packaged dev app, we need to figure out when and how to set isElectronPublish to true. Any proposals?


I also collected a pros-cons list if we decide always to minify the code:

Pros:

  • Precisely the same will be released, which was built and verified previously,
  • Consistency: simplifies the packaging logic,
  • Can help with the (manual) performance measurements.

Cons:

  • Bundle time would take an additional 20 sec due to webpack the production mode (I only guessed here and did not measure) compared to the overall ~20min package time,
  • We have to deal with minified stack traces on the FE (Note: source maps work, I could debug the bunded app with minified code, but please verify. Thanks)

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I thought source maps wouldn't work in production mode. In that case, I guess the pros outweigh the cons.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source maps wouldn't work in production mode.

Please double check if you can also debug the TS code in the bundled app. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, everything seems to work for me. Thanks @kittaakos!

Copy link
Contributor

@AlbyIanna AlbyIanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AlbyIanna AlbyIanna merged commit 78004fa into arduino:main Mar 29, 2022
@per1234 per1234 added the type: enhancement Proposed improvement label Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants