planck

Planck ClojureScript REPL
johanatan 2016-06-25T05:23:29.000450Z

Just discovered this: JSObjectCallAsFunction: https://lists.webkit.org/pipermail/webkit-help/2011-January/001849.html

johanatan 2016-06-25T05:24:21.000451Z

But I have bigger problems here now: can't do any JS/webkit/javascriptcore call from the bkg thread and I'm not sure how I could even send a message from the bkg thread to the main thread. Any ideas on that one?

mfikes 2016-06-25T05:29:55.000452Z

JavaScriptCore is supposed to be thread-safe. So you should be able to call into it from any thread.

johanatan 2016-06-25T05:34:01.000453Z

So, i can get a single JSValueMakeNumber to succeed, put it in an array and then try to create an object from that array with JSObjectMakeArray but it seg faults on the make array call

mfikes 2016-06-25T05:36:12.000455Z

If it is doing that the first thing I’d do is uncomment the memory diagnostic sanitize address thing in the Makefile: https://github.com/mfikes/planck/blob/master/planck-c/Makefile#L7

johanatan 2016-06-25T05:37:39.000458Z

Ok, trying that now

mfikes 2016-06-25T05:38:07.000459Z

You may need to make clean and then make

johanatan 2016-06-25T05:38:18.000460Z

yup, did that.

johanatan 2016-06-25T05:39:20.000461Z

doh!

johanatan 2016-06-25T05:41:53.000462Z

oh, found one stupid mistake. but after fixing that the previous (and serious one) still remains

johanatan 2016-06-25T05:42:30.000463Z

looks like JSObjectMakeArray causes a "SEGV on unknown address 0x0000000000e8"

mfikes 2016-06-25T05:42:40.000464Z

Sounds like fun. 😞

johanatan 2016-06-25T05:43:02.000465Z

the ctx passed into it is exactly the ctx that was passed to us in the main thread

johanatan 2016-06-25T05:43:25.000466Z

perhaps either a) that ctx isn't as permanent as we thought or b) ctx's can't be shared between threads like that .

mfikes 2016-06-25T05:43:26.000467Z

Well, if it helps narrow it down, I’ve never had it SEGV on me by calling from different threads.

johanatan 2016-06-25T05:43:34.000468Z

i'm leaning more towards the former

mfikes 2016-06-25T05:43:56.000469Z

Good thing is that it is pretty well documented by Apple

johanatan 2016-06-25T05:44:04.000470Z

but then again it's the same ctx that was just used for creating a number

johanatan 2016-06-25T05:45:12.000471Z

well, early day tomorrow for me. I'll look at it again tomorrow afternoon/evening.

mfikes 2016-06-25T05:45:17.000472Z

Well, so the API itself, JavaScriptCore, is a thread safe API.

You can call into various JSContext and evaluate code and create values and that sort of thing on different threads and everything will work fine.

mfikes 2016-06-25T05:45:30.000473Z

Good video on it, that’s from the transcript: http://asciiwwdc.com/2013/sessions/615

mfikes 2016-06-25T05:46:29.000475Z

Yeah, it is late here as well (East Coast US)

slipset 2016-06-25T06:47:19.000476Z

@johanatan: a bit late to the party, but I’ve done this

slipset 2016-06-25T06:49:02.000478Z

basically, when I want to listen to a socket, I pass a callback, in the form of a String: https://github.com/slipset/planck/blob/sockets/planck/PLKClojureScriptEngine.m#L713-L732

slipset 2016-06-25T06:49:51.000480Z

and execute this callback in an iife like so:

johanatan 2016-06-25T18:01:28.000487Z

@slipset: cool but are you doing that from a bkg thread?

johanatan 2016-06-25T18:02:16.000488Z

Executing the callback isn't the problem right now-- it's the segfault lol

johanatan 2016-06-25T18:03:14.000489Z

@mfikes: that's weird. I can't see anything else it could be. My JSContext looks legit and I was just previously able to create a JSNumber on it

johanatan 2016-06-25T18:04:00.000490Z

And taking that number, packing it in an array and calling JSObjectMakeArray causes the segfault

johanatan 2016-06-25T18:04:14.000491Z

Perhaps you can take a look if I push to my fork?

mfikes 2016-06-25T18:04:51.000492Z

@johanatan: yeah, I may have some free time tonight to take a look

johanatan 2016-06-25T18:05:56.000493Z

K, I'll do that in ~3-4 hours or so

👍 1
slipset 2016-06-25T18:36:24.000494Z

@johanatan: no, it's running in the same thread, but I needed a way to get noticed when someone wrote on the socket, hence the callback.