AndroidJSCore icon indicating copy to clipboard operation
AndroidJSCore copied to clipboard

How can I cancel evaluateScript execution on infinite loops?

Open tharvey opened this issue 10 years ago • 1 comments

I'm needing a way to break out of the execution of evaluationScript. In my use case I'm executing code which may loop forever. Is there an exit condition I can set somewhere?

Tim

tharvey avatar Oct 01 '16 03:10 tharvey

The way it is currently designed, there is no built-in way to do that. If you need that kind of functionality, I suggest that you create a Thread in which the JS code runs. Any interactions you have with JS will need to occur in that thread, which may mean that you have to post messages to the thread from other threads to interact with JS. When you want to kill the running JS, you would call Thread.interrupt() on your JS thread.

This is untested and potentially dangerous. I would suggest not writing code that may loop forever as a first choice.

ericwlange avatar Nov 15 '16 06:11 ericwlange