-
I wasn't aware of your UI framework--it looks very impressive, thanks for bringing it to my attention! I'll definitely look more into your framework once I get my Bangle.js v2 (since it has a full touchscreen).
Thanks also for the explanation about what happens during an upload. Overloading the Espruino interpreter buffer on upload could indeed be what happened in my case. The IDE crash behavior was the same when uploading my very large app to either the emulator or my Bangle.js.
-
Hi @Robin,
Thanks, I tend to do most development using the IDE Emulator (since it's faster than the actual hardware) and I just discovered that my full app code I minified for Bangle.js v2 that works for the Bangle.js v1 emulator gets a strange error and doesn't run on my actual Bangle.js v1 hardware.
By the way, I believe version 2v10 of the firmware somehow increased the amount of usable memory so here are the numbers I get on my real Bangle.js v1 after connecting and before loading anything:
>process.env ={ VERSION: "2v10", GIT_COMMIT: "63dafbf9f", BOARD: "BANGLEJS", FLASH: 524288, SPIFLASH: 4194304, HWVERSION: 1, STORAGE: 4194304, RAM: 65536, SERIAL: "8614df71-b4fb9fc0", CONSOLE: "Bluetooth", MODULES: "Flash,Storage,hea" ... "tensorflow,locale", EXPTR: 536882372 } >process.memory() ={ free: 1928, usage: 656, total: 2584, history: 11, gc: 27, gctime: 5.79833984375, blocksize: 13, stackEndAddress: 536925152, flash_start: 0, flash_binary_end: 450188, flash_code_start: 1610612736, flash_length: 524288 } >
That's a good point about Espruino needing space for housekeeping. I've actually been very pleasantly surprised by how much I was able to do before I started running into out-of-memory problems at runtime. And I believe the Bangle.js v2 has 4x more memory so can't wait to receive mine!
-
Hello Robin, Gordon,
Sorry if I caused any confusion. Just to clarify, the app I uploaded to this post (that is a subset of a much larger app) results in the 'JSCODE' exceeded error for me on Chrome/Ubuntu with the non-beta Web IDE Bangle.js v1 Emulator. I've just confirmed that with the change Gordon made, the (subset) app does now successfully minify/upload for me on the same Chrome/Ubuntu system using the beta Web IDE Bangle.js v1 Emulator. Also, by entering 'window.localStorage.clear()' after getting the 'JSCODE' error in the non-beta IDE, the (subset) app can also be successfully uploaded/minified.
My full app (that I have not posted here) results in an "Execution Interrupted"/"Prompt not detected - upload failed" IDE crash even with the beta Web IDE Bangle.js v1 Emulator on both Windows and Ubuntu. However--and this is great news--my full app does successfully upload/minify with either the non-beta or beta Bangle.js v2 Web IDE Emulator on Ubuntu. Moreover, I just discovered that I can download the minified source code from the Bangle.js v2 emulator and upload it into storage in the Bangle.js v1 emulator, and the minified version of the source reduces the process.memory() usage from 1239 down to 1215. I had to make a couple of minor changes to the minified source code to get the app to run but it seems to run fine. Oh, and I forgot to mention that the message I receive when uploading my full app to the v2 Emulator is "No errors. Minified 74751 bytes to 37349 bytes."
Hope that clarifies things--thank you both very much again for your help!
-
Thanks Gordon for following up on this!
Below I've attached the result of what happened after I pasted what you requested into the Chrome/Ubuntu console. I'm sorry I don't understand what you mean by "offline mode", however the good news is that after entering window.localStorage.clear() into the Chrome console I was able to upload and minify my source code. I also tried pasting my full app into the source code pane and tried to upload it, and got the same "Execution interrupted" errors as I did on Windows. If there's anything else you'd like me to do to help track down what's happening, please let me know.
In the meantime, I believe I read somewhere in the Espruino documentation about Linux command-line development tools so I'll try to see if those will allow me to minify my full app (~2.5K lines, ~80K).
-
Oh, the mystery deepens! I see the same behavior on Ubuntu regardless of which minification setting I use, even when it's turned off. And sorry for not doing this sooner but when I looked at Chrome's debug console I noticed "'JSCODE' exceeded the quota" errors when doing "Send to Espruino". From what I could learn by searching for the error it appears that Chrome ran out of storage, but as shown in the attached screenshot it still seems to have plenty available.
If whoever develops the Web IDE has any suggestions on what to try next I'd be happy to do more investigation as I can reproduce the issue consistently on my machine.
-
Wow Robin, thank you so much for all the helpful info and links about how memory is handled in Espruino! And thank you also for thinking to ask what browser/OS I use and for actually running my code. I have been using Chrome on Ubuntu and the Web IDE has been working so well that it never occurred to me that my OS might be relevant. Well I just tried uploading my code with Chrome/Windows 10 and it was successfully minified and uploaded, thank you! (And this surprised me because my Windows machine has half as much memory as by Ubuntu box, 8G vs 16G).
Unfortunately, the code I uploaded here is just a small subset of my app. If I put my app's full source code into the right-hand pane of the IDE on Windows and do "Send to Espruino"/RAM then I get the crash-like behavior I think Gordon was alluding to. Specifically, the message "Execution Interrupted" is written many times to the console followed by "Prompt not detected - upload failed. Trying to recover...". If I do "Send to Espruino"/Storage as Gordon mentioned I am able to upload my full source code but it isn't minified. So I guess I will have to employ some of the tricks you've kindly referenced to reduce the size of my app.
Well hopefully this post will be of some help to others who run into problems with large apps.
Thanks again Robin and Gordon for your gracious help with my issue!
-
Thank you very much for your reply Gordon, and congratulations on another successful Kickstarter campaign!
I was indeed uploading my code to the emulator, but whether I try to upload it to the emulator or my Bangle.js the result is the same (i.e., nothing happens). After clicking the upload ("Send to Espruino") button, the left-hand pane of the IDE flashes briefly, but I can still interact with it normally. If I click the down-arrow and enter a storage file, again nothing happens, and I can still interact with the left-hand pane as usual.
I would not be at all surprised if there's something in my code causing the problem, however as I noted previously if I cut-and-paste each function alone into the right-hand pane, each one is uploaded successfully without any EMSCRIPTEN errors. The problem only occurs when I try to upload all the functions at once, leading me to believe I'd exceeded some size limit.
Anyway, I have attached a file that reproduces the problem in the emulator and my Bangle.js. I'm not sure it adheres completely to the recommended coding guidelines but I think it's pretty close. Thank you in advance for investigating the issue and pointing out any obvious missteps in my code (I'm still learning how to write code for my Bangle.js).
Best of luck with Bangle.js v2, I can't wait to receive mine and start updating my apps for it!
-
Thank you very much for your reply Robin!
"Send to Espruino" was working for me fine until I believe my code reached a certain size. After that, it no longer worked no matter how many times I hit "Send to Espruino".
I'm using v 0.75.11 of the Web IDE (sorry for neglecting to include that earlier).
I entered process.env into the left-hand side of the IDE after running my program from storage and here's what it returned:
>process.env ={ VERSION: "2v10.90", GIT_COMMIT: "e60188501", BOARD: "EMSCRIPTEN", FLASH: 4194304, SPIFLASH: 4194304, HWVERSION: 1, STORAGE: 4194304, RAM: 0, SERIAL: "00000000-addeadde-addeadde", CONSOLE: "USB", MODULES: "Flash,Storage,hea" ... "tensorflow,locale", EXPTR: 94208 } >
Hopefully that is the info you wanted to see, please let me know if you wanted something else (I obviously still have lots to learn about Espruino).
In the last line of my program, I printed process.memory() to the console and this is what was printed:
{ "free": 2271, "usage": 229, "total": 2500, "history": 0, "gc": 0, "gctime": 0, "blocksize": 13 } >
My program consists of 4 functions and "Send to Espruino" works fine if I load the first two functions but when I add in the third--and by that I mean add it to the right-hand source code pane--then "Send to Espruino" no longer does anything. After loading the second function in the source code pane, and doing "Send to Espruino" that should only have loaded the first two functions (and a few global variables) into memory, process.memory() returned:
>process.memory() ={ free: 2426, usage: 74, total: 2500, history: 1, gc: 0, gctime: 1, blocksize: 13 } >
If I paste nothing else but the third function into the source code pane and do "Send to Espruino", it works and the IDE tells me "No errors. Minified 6259 bytes to 2802 bytes."
Sorry but I don't really understand how to interpret the numbers returned by process.memory() or trace() for that matter . When I load my full program into my Bangle.js storage, run it and log process.memory() to the console at the end, it returns:
{ "free": 2278, "usage": 306, "total": 2584, "history": 0, "gc": 0, "gctime": 4.66918945312, "blocksize": 13, "stackEndAddress": 536925152, "flash_start": 0, "flash_binary_end": 450188, "flash_code_start": 1610612736, "flash_length": 524288 } >
Thank you for offering to help me figure out what's going on. My full program (of which these four functions are only a part) is ~2.5K lines/~80K. That runs fine on my Bangle.js from storage, but of course "Send to Espruino" doesn't work for that large program either. I've had to limit some features of my full program due to running out of memory so if I could get the IDE to minify my programs that would be great.
-
Hello,
I've noticed that after a while, "Send to Espruino" in the Web IDE stops working. It seems to happen once the code exceeds a certain size. In my case, I'm seeing this with a 250 line, ~8k file. I don't see any errors listed in the IDE's console (or Javascript errors flagged in my code), clicking "Send to Espruino" simply appears not to do anything anymore. I can work around this by uploading the file to storage and running it from there, but then I lose the memory benefit of the IDE's automatic minification. I also set the pretokenise flag at the top of my file, but haven't seen any obvious memory reduction.
Well if anybody can offer any hints on what's going on and how I can get "Send to Espruino" working again, I would greatly appreciate it. I'm having a great time building apps for my Bangle.js and can't wait to receive the latest version!
-
Thank you very much @allObjects and @Gordon for spending the time looking into this and resolving the issue!
-
I am also pleased to report that the emulator is now working for me too (in the States).
A brilliant realization and fix @Gordon, thank you! -
Thanks @allObjects, for your reply and suggestion!
I just tried adding the "predraw" option to set a larger font but it didn't seem to have any effect (or result in any errors). Here's my updated code, thank you in advance for checking to see if I did something incorrectly:
var mainMenu = { "" : { "title" : "-- Main Menu --", "fontHeight": 40, "predraw" : function(gfx) { gfx.setFont("Vector", 40); } }, "Item 1" : function() { undefined; }, "Item 2" : function() { undefined; }, }; E.showMenu(mainMenu);
-
Yes, the pop-up emulator appears but with blank content. There's also another "SELECT A PORT..." pop-up window the reads "CONNECTING...". I've tried refreshing the emulator window and closing it and refreshing the main IDE page and connecting to the emulator again but still get the same result.
I don't think any code from the right-side of the IDE is being loaded, presumably because the connection to the emulator never succeeds. Chrome seems to cache whatever was last entered into the right-hand side, so the content of my right-hand pane is different from yours (and is the code I most recently uploaded to my watch).
-
Hello Fellow Bangle.js Fans,
Novice Bangle.js app developer here, so please be kind. The default font used by E.showMenu() is a bit too small for me to read so I'm trying to increase its height. I tried setting the 'fontHeight' menuinfo attribute described on the "Graphical Menu" reference page, but it doesn't seem to have any effect. Changing the 'title' attribute does change the title so I think my code isn't completely wrong. If somebody would be kind enough to review my code below and tell me what I've done wrong I'd appreciate it!
var mainMenu = { "" : { "title" : "-- Main Menu --", "fontHeight": 40, }, // no effect? "Item 1" : function() { undefined; }, "Item 2" : function() { undefined; }, }; E.showMenu(mainMenu);
-
Hello,
I just wanted to add that I haven't been able to get the Emulator to work either, even after following the refresh steps noted previously. Fortunately, I do have a watch but it would still really be handy to test code using the emulator. Anyway, I'm using Chrome on Ubuntu 18. In case it helps, I see the same behavior and console output @sebi showed in the screenshot for post #37 but with the addition of the following error at the very end:
DevTools failed to load source map: Could not load content for https://www.espruino.com/ide/secure-dfu.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
Hope this helps diagnose/resolve the issue.
@Robin,
The values in my screenshot for post #22 came from the Web IDE connected to my Bangle.js v1. I actually never even noticed the blocksize before and haven't done anything I'm aware of to change the default value. 13 definitely seems like an odd number, though.