Schmavery / reprocessing

ReasonML graphics library inspired by Processing
https://schmavery.github.io/reprocessing/
MIT License
682 stars 24 forks source link

Interaction with vscode-reasonml causes hot reload crash #68

Closed vtrrsl closed 6 years ago

vtrrsl commented 6 years ago

Hi! Thanks for an exiting project! I'm trying out the reprocessing-example, it builds, but crashes when trying to hot reload. The steps are:

npm run build

> reprocessing-example@ build /Users/xxx/code/reason/processing/reprocessing-example
> bsb -make-world

[2/2] Building fake_src/sdl_index.mlast.d
[2/2] Building lib.cma
[4/4] Building run_build_script
[3/3] Building lib.cma
[4/4] Building run_build_script
[3/3] Building lib.cma
[18/18] Building run_build_script
[10/10] Building lib.cma
ninja: no work to do.
ninja: Entering directory `lib/bs/bytecode'
[4/4] Building src/index.mlast.d
[3/3] Building indexhot.byte

This process finishes and then I run:

npm start

> reprocessing-example@ start /Users/xxx/code/reason/processing/reprocessing-example
> ./lib/bs/bytecode/indexhot.byte

Rebuilding hotloaded module
Succesfully changed functions
Rebuilding hotloaded module
Succesfully changed functions
Rebuilding hotloaded module
Succesfully changed functions
Rebuilding hotloaded module
File "src/index.re", line 1:
Error: I/O error: lib/bs/bytecode/src/index.re.cmi: No such file or directory
Hotreload failed
Fatal error: exception Failure("Unknown error while loading plugin")
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! reprocessing-example@ start: `./lib/bs/bytecode/indexhot.byte`
npm ERR! Exit status 2 reprocessing-example master

It builds successfully and the first hot reload works, but after a second change in src/index.re it crashes with the exception above

bsansouci commented 6 years ago

Hey thanks for reporting, are you on linux? Could you show the contents of lib/bs/bytecode/ and lib/bs/bytecode/src after the crash?

Not totally sure what's going on here.

vtrrsl commented 6 years ago

I'm on macOS 10.13.3 This is the contents before:

1

After the crash the whole /bytecode directory is gone:

2

ArcherDs commented 6 years ago

I have the same problem and i solved it by consulting the branch 2048 and adding some dependencies "dependencies": { "FontGenerator": "bsansouci/font-generator", "reprocessing": "schmavery/reprocessing" }, "devDependencies": { "bs-platform": "bsansouci/bsb-native#2.1.1", "font-generator": "bsansouci/font-generator" }

vtrrsl commented 6 years ago

@ArcherDs Thanks for your comment, adding those doesn't fix the problem for me though

Schmavery commented 6 years ago

@vtrrsl on my mac, I ran

git clone https://github.com/bsansouci/reprocessing-example.git
cd reprocessing-example
npm install
npm run build
npm run start

and then edited src/index.re several times while saving to test hot reloading and unfortunately haven't had any success reproducing this.

Would you say this sequence of steps accurately describes the process required to consistently reproduce this error on your machine?

ArcherDs commented 6 years ago

In my experience,because some of the dependencies's version don't change (always 0.1.0),so npm and yarn maybe cache the old repository,i guess this make the building progress error prone. After i run yarn cache clean (npm cache clean) and totally reinstall the project ,it works.

Schmavery commented 6 years ago

Thanks for trying again! You had me getting nervous for a second there :P

Great suggestion about the version, we're planning to publish to npm soon with some proper docs and will probably handle the versions better after that!

vtrrsl commented 6 years ago

So I found the issue, when I disable vscode-reasonml it all works fine, I think that when it formats the code it messes things up with the hot reloading. Thanks for all the help though!

Schmavery commented 6 years ago

Thanks for the new info, @vtrrsl, looks like something worth us looking into and trying to improve if we can. We have a better hotreloader coming down the pipeline so that may help, we'll see.

vtrrsl commented 6 years ago

Sounds great, thanks again!

bsansouci commented 6 years ago

This should be fixed since @vkammerer pushed his change.