Arcadia icon indicating copy to clipboard operation
Arcadia copied to clipboard

REPL in exported App

Open nasser opened this issue 11 years ago • 13 comments

Optionally embed a REPL in an exported app for debugging and instrumentation.

nasser avatar Aug 28 '14 14:08 nasser

This would be amazing; has there been any work done for it?

jeaye avatar Apr 24 '16 05:04 jeaye

It is theoretically possible on some platforms, but we have not had a chance to try it yet. Short answer: it should work on exported desktop games, probably won't ever work on mobile or consoles.

Long answer: some export platforms disallow runtime code emission, i.e. the generation of new executable code while a program is running. This is done for security reasons and happens on the kernel level, so we can't sidestep it. We've confirmed this to be the case on iOS, the web and the PS4, but it probably applies to all mobile and console targets as well.

A Clojure REPL emits code when it compiles and executes forms, so an exported REPL on these platforms will never be possible given the current compiler architecture. This limitation is also what makes exporting normal Clojure code to these platforms difficult, as the compiler uses optimizations that modify the bytecode at runtime, which is also rejected by these platforms for the same reason.

nasser avatar Apr 27 '16 14:04 nasser

Confirmed working on desktop and Android! Just need to clean it up a bit. It will be in the first alpha.

nasser avatar Aug 23 '16 19:08 nasser

Wait, Arcadia is working on Android now as well? I didn't use it for my last project because I was told Android wasn't supported (IL2CPP issues).

jeaye avatar Aug 23 '16 20:08 jeaye

Yeah! We've learned not to trust what we read and just build things. Unity doesn't AOT anything for Android, it seems. We have export and a REPL on the device.

nasser avatar Aug 24 '16 04:08 nasser

Badass! Nice work and thanks for the update.

jeaye avatar Aug 24 '16 04:08 jeaye

maybe this issue should include:

  • fixing up arcadia.repl to be a buildable ns
  • fixing android export (currently you have to manually AOT your project and copy to build?)

selfsame avatar Dec 17 '16 17:12 selfsame

  • arcadia.repl is very close, its really our config story thats still something of a mess and editor dependent
  • android export should Just Work, but only clojure.core, arcadia.core and the namespaces of vars on your hooks (and their requires) will be automatically AOT'd. If you want more namespaces to show up in the exported app, you need to :require them or manually AOT them.

nasser avatar Dec 17 '16 17:12 nasser

I think reader conditionals would help a lot with this. Maybe we can map Unity's #define directives to arcadia specific keywords like :unity-editor, :unity-android, etc.

spacepluk avatar Dec 17 '16 18:12 spacepluk

ah ok wasn't sure if the android build aot stuff had been fixed or not.

reader conditionals for build target/editor would be very cool, or at the least some sort of ns meta like in https://github.com/arcadia-unity/Arcadia/issues/184#issuecomment-252267986

selfsame avatar Dec 17 '16 18:12 selfsame

About the android export, I'm not sure if this is a linux-specific issue but in my case BuildPostProcess was running after the apk was sent to the device which wasn't very useful. So I ended up deleting BuildPostProcess.cs and AOTing some namespaces manually.

spacepluk avatar Dec 18 '16 10:12 spacepluk

That's a limitation of Unity's export hooks. It seems to run them after it uploads the apk. What I've done is hit Build then upload the apk myself.

nasser avatar Dec 20 '16 20:12 nasser

  • [ ]  disentangle config
  • [ ]  use main-thread-callback (or whatever) ns for driver
  • [ ]  make main-thread-callback ns easily externally drivable from the main thread by a variety of mechanisms (including export-amenable ones) and have it test that it's running on the main thread

timsgardner avatar Mar 11 '17 21:03 timsgardner