vegetableman / vandal

Navigator for Web Archive
https://vegetableman.github.io/vandal/
GNU Affero General Public License v3.0
151 stars 6 forks source link

Future of Historical View #1

Open vegetableman opened 3 years ago

vegetableman commented 3 years ago

Historical view displays a single snapshot of a webpage for each year that it's been archived for. It uses Puppeteer to capture screenshots which in turn runs on AWS Lambda as a serverless function. Screenshots are not free. For now, the service is running on AWS Free Tier and is free for 1M free requests per month until September this year. So, it likely will only last until then.

Also, It's just not a good user experience, as it's been throttled to around 5 seconds for each snapshot to reduce load on Archive servers. Hopefully Wayback could support something like this in the future.

trumad commented 3 years ago

You could potentially fetch the html source of each year's page, then pop it into a sandboxed iframe:

var base64Source = btoa(unescape(encodeURIComponent(sourceHtml,currentHref,contentType))); var iframeHtml = <iframe src="data:+contentType+;base64,+base64Source+" sandbox width="100%" height="300px"></iframe>;

But you've probably already tried something like this and it didn't work?

vegetableman commented 3 years ago

@trumad Tried it 😄. Too many iframes result in larger memory footprint messing up the tab and not to forget, scroll jank. Also, It's a bit like watching living, breathing creatures clamoring to get out of those mini cages.

trumad commented 3 years ago

lol, I've never thought of it that way. Those poor creatues... Could you make an iframe and then immediately screenshot it in the user's browser, then replace the iframe with a screenshot? I'm not sure how possible that is. I know it's easy to use canvas to get a screenshot, but I don't know about a whole iframe. Just spitballing, hope you don't mind!

vegetableman commented 3 years ago

Just spitballing, hope you don't mind!

Of course not.

Could you make an iframe and then immediately screenshot it in the user's browser, then replace the iframe with a screenshot?

It would be too many dom construction and destruction for a simple use-case, will probably mess up the framerate, making it unusable for the user. Also, for screenshots, html2canvas would have to be injected in to those frames somehow but if I recall correctly, it gives out inconsistent screenshots. Some styles are never captured. so, html2canvas is out.

Another option: https://developer.chrome.com/docs/extensions/reference/tabs/#method-captureVisibleTab But that would require a tab with the archive url to be already open for the screenshot to work. So, it could become a case of opening and closing tabs for each archive url for taking a screenshot. again, not a good (more like silly) user experience.

Another option: https://blog.stackblitz.com/posts/introducing-webcontainers/. Run node on the browser and invoke puppeteer with in the browser to take a screenshot 🤯. That would be fun 😂.

trumad commented 3 years ago

Yeah, it sounds like html2canvas would be too janky, and opening & closing new tabs would be even worse. You've clearly given this a lot of thought.

Another option: https://blog.stackblitz.com/posts/introducing-webcontainers/. Run node on the browser and invoke puppeteer with in the browser to take a screenshot 🤯. That would be fun 😂.

That's the dumbest thing I ever heard. You should do it!