rive-app / rive-wasm

Wasm/JS runtime for Rive
MIT License
735 stars 52 forks source link

rive.wasm file size: >3x increase on 2.x.x versions #332

Closed tomek-f closed 11 months ago

tomek-f commented 1 year ago

1.2.4 - 204 kB (~90kB gzipped) https://www.npmjs.com/package/@rive-app/canvas/v/1.2.4?activeTab=code

2.1.1 - 653 kB (268kB gzipped) https://www.npmjs.com/package/@rive-app/canvas/v/2.1.1?activeTab=code

There's no info in the changelog https://github.com/rive-app/rive-wasm/blob/master/CHANGELOG.md

Tiny file size Rive files are a fraction of the size of videos, GIFs, image sequences, or JSON-based formats. Whether you bundle your animations or deliver them remotely, our optimized format helps keep your app small.

Yup. Rive files are tiny, but the runtime is huge ;)

Is it a bug (eg. bad/unused imports)?

Is there smething that can be done to reduce the runtime size?

zplata commented 1 year ago

Hi @tomek-f ! Something went up in the release process for automating the CHANGELOG so thanks for pointing this out, we'll get this fixed up.

Regarding the runtime size, you're right, the WASM runtime got a major version bump from v1 to v2 due to a size increase for having a quite complex text engine compiled into the .wasm that powers the runtime. We're actively looking to optimize this such as determining which WASM to load when you instantiate Rive (i.e. detecting if you need a version with the text engine), loading the text engine on demand if needed, or even a more pared-down version to cut down on the size. We can keep this issue up until we have a solution released for this in the meantime.

If you don't have a need for Rive Text, you should use v1.2.4 and you'll have a much smaller dependency size from @rive-app/canvas

tomek-f commented 1 year ago

Thanks, @zplata

dross15 commented 1 year ago

Have there been any updates in regard to this issue? We tried using v1.2.4 but with the latest version of rive-app/react-canvas (4.3.3) our animations were breaking, and we had to bump to v2.4.3. When working within Next.js (next.config.js) it causes our maxAssetSize to nearly 4x in size.

zplata commented 1 year ago

Hi - we should have a version coming out pretty soon here barring any complications in our testing! It will look something along the lines of consuming either a @rive-app/canvas-lite / @rive-app/canvas-advanved-lite and probably a React one as well. It should be about a third of the size it is today.

zplata commented 1 year ago

Hey all! We just released the packages mentioned above, @rive-app/canvas-lite and @rive-app/canvas-advanced-lite as v0.1.1. After we do some testing and validation, this should shortly align with the other web runtime versions. But feel free to use v0.1.1 now!

Note that this package will not have the text engine dependencies needed to render Rive Text, so if you have any .riv assets that have that, it will not render (but it will also not break your app if it does have it, or if you use the text APIs). Let us know if you run into issues with this.

Once this is validated, we'll likely make a @rive-app/react-canvas-lite or something of the sort.

zplata commented 11 months ago

@rive-app/react-canvas-lite is available and updated alongside the regular js/wasm runtimes! You should hopefully see a noticeable package size drop if you integrate either the @rive-app/canvas-lite or @rive-app/react-canvas-lite packages. Closing for now but feel free to open a new issue if you run into issues with it.

tomek-f commented 11 months ago

Thank you, @zplata