edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Adam Thompson <arthompson1990@gmail.com>
To: Karl Dahlke <eklhad@comcast.net>
Cc: Edbrowse-dev@lists.the-brannons.com
Subject: Re: [Edbrowse-dev] JS1
Date: Fri, 28 Jul 2017 19:51:03 +0000	[thread overview]
Message-ID: <20170728195103.GE20415@odin> (raw)
In-Reply-To: <20170628133910.eklhad@comcast.net>

On Fri, Jul 28, 2017 at 01:39:10PM -0400, Karl Dahlke wrote:
> > Ok, so how're we going to do all the async js stuff we'll have to start doing
> > properly soon? Tbh I'm not sure how much I'm attached to the multiple process
> > idea other than it means js can go pop and we don't...
> 
> Right. They are orthogonal issues.
> We're not going to spin off a separate process for every asynchronous thing that the browser might do,
> it will either be threads or some sort of time share polling,
> so the separate process was necessary due to the fragility of js,
> but I think we're fixing that step by step, and when the js side is as solid as the edbrowse side I'd like to fold them back together into one process,
> which the JS1 variable is a start.
> I may add some more code over the next week, still under JS1, to simplify the code when it is one process.
> So many times we can just call a function instead of passing messages around, and we wouldn't even need all those updates when curl data changes etc,
> so something to work towards.

They're kind of authogonal and kind of not.  With the separate process we can
keep spinning round the main input loop even if js is stuck in some expensive
operation... I can switch buffers and get on with browsing whilst the page in
buffer 1 does its thing.  We can do that by polling a pipe or switching to some
non-blocking IO.  With js in the same process we've got to either spin it up in
a separate thread (inwhich case anything which interacts with the main edbrowse
ui has to be thread-safe) or the browser grinds to a halt when someone puts an
ill-advised loop into their js.  If we can find a way to make the code
thread-safe or get duktape to do collaberative multithreading (i.e. stop after a
certain amount of instructions to allow us to spin round the main loop
again) I really don't mind, but it's just something to think about.  It'd be
nice to simplify (if not altogether remove) the code to sync the edbrowse and js
worlds however.

If I can get some time in front of a computer this weekend I'll have a look at
how much work this'll be to make happen.

> As for the larger question, I don't think I know enough yet to answer.
> Honestly it makes me nervous to think of making all of edbrowse + duktape threadsafe.

Same here... lots of ways things could go badly wrong!

> Javascrip timers are implemented now, and well tested, e.g. http://www.eklhad.net/async
> They don't spin on cpu cycles, they actually use timers, but they also signal the main input loop so that everything is serialized.
> We process what you typed in, or we run the js code associated with a timer, and we're back.
> There aren't any threads, and it works pretty well.

Yeah, that's a good example of how this stuff can work.

> I'm not saying that will work for everything we need to do, I just don't know enough yet,
> but if it would work for other situations it would be easier.

Agreed, I'm particularly worried about websites' increasing reliance on AJAX
being genuinely async and then there's websockets (which'll have to happen
sometime... unfortunately).  I know we can multiplex sockets and that'll work
well but it'll be complex.

Cheers,
Adam.

  reply	other threads:[~2017-07-28 19:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-23  2:49 Karl Dahlke
2017-07-24 17:57 ` Adam Thompson
2017-07-28 17:39   ` Karl Dahlke
2017-07-28 19:51     ` Adam Thompson [this message]
2017-07-28 22:05       ` Karl Dahlke
2017-08-11  7:46         ` Adam Thompson
2017-08-11  9:51           ` Karl Dahlke
2017-08-12  7:20             ` Kevin Carhart
2017-08-12  7:30               ` Karl Dahlke
2017-08-12  8:06                 ` Kevin Carhart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170728195103.GE20415@odin \
    --to=arthompson1990@gmail.com \
    --cc=Edbrowse-dev@lists.the-brannons.com \
    --cc=eklhad@comcast.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).