2

I am processing UI instructions on a virtual machine (V8 actually) on Android in the main UI thread. This works fine. However, now I'm adding a JavaScript debugger into the mix (Stetho in my case). I can pause the UI thread when a breakpoint is hit, and even step through instructions. However, when an instruction changes the UI, the UI is not immediately updated. Instead, the view is invalidated and only when the main event loop continues processing will the updates render.

So my question is, can I force a redraw of the entire device from the UI thread without returning to the main loop? If I return to the main loop then I will blow my entire call stack, and pausing during debugging will no longer work.

I tried to get the main Looper, and I can even call Loop() on it (ideally to start processing the events), but then this will become the main loop (and you cannot quit the main looper). If anyone has any thoughts on how to simulate the main event loop, that would be greatly appreciated.

irbull
  • 2,490
  • 2
  • 20
  • 28

1 Answers1

1

This is fun, I'm doing the same thing as you, creating a bridge between J2V8 and Stetho. The trick is to run the debugger in it's own thread. Since the debugger will have direct access to V8, it can easily manipulate the runtime, but commands going to Native code (like UI commands) will run on the main thread until they come back to the V8 runtime.

Arkain
  • 918
  • 6
  • 10