Closed lavelle closed 11 years ago
This is a good run-down of the issues and options. See https://github.com/jvilk/BrowserFS/ for our current progress. :+1:
(Pull requests are welcome there as well!)
This is an area that I heavily worked on before the summer in BrowserFS, and I hope to get back to. We're fairly close to having enough functionality to switch over to using it in Doppio.
The main issue right now is that I need to add support to some synchronous fs functions that Doppio uses (we perform synchronous writes to files in Doppio, and BFS is currently 100% async). Once we add optional sync API support and add it to the localStorage FS in BrowserFS, we can iterate on moving toward IndexedDB.
Also, BFS will allow us to degrade to the 'best' persistent storage API available. So if we add Web SQL support, we'll be able to use that when IndexedDB isn't available.
Also, as a hacky workaround, we support saving files in-memory without persisting to localStorage
in the browser. It's an extra flag to one of the fs
commands... I know we use it for preloading files.
Ha, we already use the hack to ensure that written files don't hit localStorage! :smile:
https://github.com/int3/doppio/blob/master/src/runtime.coffee#L227
I'll commit something that exposes this option to the browser console.
Darn. I need to sleep now.
In my local copy of Doppio, I added the following to the top of the browser java
command:
jvm.dump_state = false
# XXX: dump-state support
for i in [0...args.length]
if args[i] is '-Xdump-state'
jvm.dump_state = true
args.splice i, 1
break
However, it doesn't appear to trigger state dumping. :frowning:
Here's my test class that I used that triggers state dumping on the console but not in the browser:
class Test {
public static void main(String[] args) {
throw new Error("Hey");
}
}
I'll try to do this tomorrow if no one fixes it before me.
@lavelle: I've added -Xdump-state
support to the browser. it doesn't persist the dump, so you'll need to edit
the file to copy+paste it locally to use it with the state viewing tool we have. I hope this makes things a little easier.
Also, as for the Webrick hook, I already created a mechanism for piping stdout
through POST messages for the benchmark
build. I haven't tested it or checked it recently, so who knows if we've broken it.
Feel free to hack in a handler for POSTing arbitrary files through Webrick. You could detect the browser environment by checking if node
is a global variable, and use that to channel any needed debug info through Webrick.
Please let me know if there is anything specifically that you'd like us to do. I'm planning to reserve part of the weekend for Doppio/BrowserFS work. And feel free to use cycles on improving the in-browser development experience; it's basically a requirement for you to be productive on the Swing project, as you've mentioned.
re: dump-state, it would be super nice to integrate the core viewer that Jez wrote into the frontend.
Closing this for now, as we have existing issues that encapsulate current filesystem issues (asynchronicity / cloud storage / indexedDB support).
Working on Swing support has left me wanting a better development workflow for the browser interface to Doppio – most Swing-related classes throw a
HeadlessException
somewhere, leaving the browser the only place they can be debugged.The browser filesystem needs to be improved before I can work on improving the development tools though – for example adding support for
-Xcore-dump
requires more than 5mb for the ability to dump a stack of arbitrary size, and even then to save it permanently would require copying and pasting.This issue outlines the options available for improving the filesystem in the browser.
Browser APIs
There are 4 main APIs available for persistent storage in modern web browsers:
localStorage
). This is what is currently used and, while having a very simple API, is limited to 5mb of storage in total.webkit
prefix. Lets the application request an arbitrary amount of data, that the user is prompted to allow or deny. Despite being Chrome-only, I think this is worth considering. Chrome is the most popular browser, access to arbitrary storage would make development a lot easier, and we could still fall back tolocalStorage
on other browsers. This has the advantage of being the only browser API that actually writes files in their original state to disk, making it the easiest to access from outside the browser.Other options
browser_fs
directory created in the project root. This would only work for development though, obviously.