Skip to content

Trying to stop the execution of JavaScript code within a JSContext

Notifications You must be signed in to change notification settings

juanjo-ramos/StopJavaScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

StopJavaScript

This project doesn't aim to kill JavaScript (well, hold on 🤔) but tries to stop the execution of some JS code running in a JSContext. Situation:

  • You have some JS code you want to run.
  • That code takes a significant amount of time to run.
  • The user can cancel the operation at any time.
  • When they do, you want to stop the execution of the JS code no matter what.

How to run this

This project is targetting iOS 13.1. Just open & run it. The different attemps I'm trying are in ViewController.swift.

Wait, but does this work or not?

It does not.

It does now. After some experimentation, it turns out that if you have a WKWebView evaluating certain JS code, you can terminate that execution by nil'ing the WKWebView object. See WKWebViewJSCore for more details.

About

Trying to stop the execution of JavaScript code within a JSContext

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published