Binary blobs in apps-store apps

Posted on
  • Hi,
    This is a bit of an app-store policy question:
    I wrote an STL viewer app (STL is a relatively simple file format for representing 3d models and is often used in the hobbyist 3d printing realm). The app can read ASCII formatted STL files and displays a shaded 3d view of its contents that can be rotated around on the watch screen (see attached image).
    I concede this is probably not the most useful app for a smartwatch, but perhaps it is still worth adding to the app store.
    However, to get even marginally useful framerates for all but the very simplest models, I ended up doing a lot of the linear algebra and data manipulations in inline C using 32 bit floats and the processor's FPU (thanks to @fanoush for figuring out how to do that). For the FPU code to compile I had to host my own local Espruino compiler.
    Therefore, in order for others to install the app on their watch the app store version would have to contain a binary blob of the compiled routines (encapsulated in a base64 string). Obviously I would provide the C code as well, but it would be much harder for the casual user to play around with the code than with a strictly JS-only app.
    Any thoughts on this?

    1 Attachment

    • IMG_20200804_170932.jpg
  • Wow, that's awesome!

    Personally I'm totally happy with including binary blobs. What some others have done is include app.js and then app.min.js which is the one that actually gets uploaded?

    What would be great is if you could let me know exactly what was changed in your compiler service so I could add it back into the one everyone has? Then at least it'd be easy for others to try your code.

  • Compiler flags are here you can perhaps make it conditional based on board name, those with nrf52832 can have cortex M4/FPU enabled. Also I enabled C preprocessor by removing -fpreprocessed which you have turned off for some reason (security because of #include running on server ?)

    and with the FPU errata fix you added recently this is even more painless since you don't need to clear that in inline C code now

  • Ok, thanks! Yes, I should be able to just check based on the board name.

    I enabled C preprocessor by removing -fpreprocessed which you have turned off for some reason

    Yes, it's because I don't want anyone doing #include "/etc/passwd" and then getting bits of it quoted back to them in an error message :)

  • Well in that case lines with #include could be stripped from source as macros and defines/ifdefs are otherwise quite handy, but it is extra work of course. Also it could run in chroot or docker, again extra work.

  • Ok, it's now live! So you should be able to compile for Bangle.js with floating point support using the normal compiler service.

    Yes, there are ways around pretokenisation (I bet #include isn't the only thing that includes files) - but to be honest it was just a matter of trying to provide a useful tool without a massive security hole or complicating it so much it never got released.

    IMO the best would be to just emscripten compile ARM GCC and run it in the browser if needed. I'd love to get as little as possible dependent on the server

  • Thanks for adding the compiler flags, it works beautifully. I put in a pull request for the app to be added to the app loader.

  • Thanks - just merged!

  • @user113695,

    absolutely cool...


    1. what is the (max, average) size of the .stl file the watch can handle?
    2. could you change the viewers point into the object space?
    3. what is the average fps per edge?
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Binary blobs in apps-store apps

Posted by Avatar for user113695 @user113695