arcadia-unity / Arcadia

Clojure in Unity
http://arcadia-unity.github.io/
Apache License 2.0
1.68k stars 108 forks source link

REPL in exported App #5

Open nasser opened 9 years ago

nasser commented 9 years ago

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

jeaye commented 8 years ago

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

nasser commented 8 years ago

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 commented 7 years ago

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

jeaye commented 7 years ago

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).

nasser commented 7 years ago

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.

jeaye commented 7 years ago

Badass! Nice work and thanks for the update.

selfsame commented 7 years ago

maybe this issue should include:

nasser commented 7 years ago
spacepluk commented 7 years ago

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.

selfsame commented 7 years ago

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

spacepluk commented 7 years ago

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.

nasser commented 7 years ago

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.

timsgardner commented 7 years ago