abhidas17695 / dweb-ext

0 stars 0 forks source link

Starting transports #30

Closed mitra42 closed 6 years ago

mitra42 commented 6 years ago

I'm currently starting transports in bootloader.js which I believe means when the extension is loaded, this starts IPFS and WebTorrent etc. That could slow things down even when not in the dweb, so I think we need. a) a flag in bootloader.js - "const startTransportsAtLoad = false" b) If that flag is set then start as now (last line of bootloader.js) c) If not set, then start the first time we intercept a matching URL.

abhidas17695 commented 6 years ago

Do we want DwebTransports.p_connect({ }); just once ? Or do we want DwebTransports.p_connect({ }); to run as many times as a new URL is intercepted ?

mitra42 commented 6 years ago

Just once - your original version ran it multiple times; the current version runs once on loading; I'd like it to run once the FIRST time a URL is intercepted, but to be able to control that behavior via the flag I mentioned 2 comments above.

abhidas17695 commented 6 years ago

I get it

mitra42 commented 6 years ago

I notice this is worked on in current release. (please comment in Git when you work on things with a related issue). I notice three things. a) Equality tests should almost always be === not == (read up on the difference, its subtle) b) There are two tests ... it should work as currently written but I think:

Combining these two things, I think this makes the desired code in the Listener. :

if (!transportsLoaded) { 
  p_connect({}).then(()->main(url, details, tabId));
} else {
  main(url,details, tabId);
}

I have not tested this yet.

mitra42 commented 6 years ago

This would explain why I see "cat find any transport", main is trying to use the transports before they are loaded.

abhidas17695 commented 6 years ago

Yes you are right. p_connect() is asynchronous so that is why the error is popping up

abhidas17695 commented 6 years ago

@mitra42 please check out the latest commit. The fix you suggested worked. Thank you

mitra42 commented 6 years ago

Will do

mitra42 commented 6 years ago

I'm seeing it running twice on each load - Notice the line "resolving arc/archive.org" twice

abhidas17695 commented 6 years ago

screenshot 6

That should not be happening. The flag transportsLoaded is used to load Dwebtransports just once. You can see the line "Transports loaded 2 times" in the screenshot above. Looking into it.

mitra42 commented 6 years ago

Sorry, I'm talking about a different problem, I wasn't clear. I think p_connect is running only once. Its loading a page twice - even when the URL dweb.archive.org is pasted in

abhidas17695 commented 6 years ago

If you reload the extension and navigate to dweb.archive.org you will see that DwebTransports is loaded twice. And the URL is also captured twice. But if you then open a new tab and navigate to dweb.archive.org you will just see that the URL is captured twice. I think this has something to do with #28

mitra42 commented 6 years ago

Agreed = if I turn off the preload the problem goes away - I'll mark this as closed.