{"id":452,"date":"2015-01-07T20:30:44","date_gmt":"2015-01-07T19:30:44","guid":{"rendered":"http:\/\/blogs.igalia.com\/xrcalvar\/?p=452"},"modified":"2015-01-08T10:22:35","modified_gmt":"2015-01-08T09:22:35","slug":"streams-api-in-webkit-at-the-web-engines-hackfest","status":"publish","type":"post","link":"https:\/\/blogs.igalia.com\/xrcalvar\/2015\/01\/07\/streams-api-in-webkit-at-the-web-engines-hackfest\/","title":{"rendered":"Streams API in WebKit at the Web Engines Hackfest"},"content":{"rendered":"<p>Yes, I know, I should have written this post before you know, blah, blah, excuse 1, blah, excuse 2, etc. \ud83d\ude09<\/p>\n<p>First of course I would like to thank <a href=\"http:\/\/www.igalia.com\">Igalia<\/a> for allowing me to use the company time to attend the <a href=\"http:\/\/www.webengineshackfest.org\/\">hackfest<\/a> and meeting such a group of amazing programmers! It was quite intense and I tried to give my best though for different reasons (coordination, personal and so on) I missed some session.<\/p>\n<p>My purpose at the hackfest was to <a href=\"https:\/\/lists.webkit.org\/pipermail\/webkit-dev\/2014-November\/026995.html\">work with Youenn Fablet<\/a> from <a href=\"http:\/\/www.canon.com\">Canon<\/a> on implementing the <a href=\"https:\/\/streams.spec.whatwg.org\/\">Streams API<\/a> in <a href=\"http:\/\/www.webkit.org\">WebKit<\/a>. When we began to work together in November, Youenn had already a prototype working with some tests, so the idea was taking that, completing, polishing and shipping it. Easy, huh? Not so&#8230;<\/p>\n<p>What is Streams? As you can read in the <a href=\"https:\/\/streams.spec.whatwg.org\/\">spec<\/a>, the idea is to create a way of handling different kind of streams with a common high level API. Those streams can be a mapping of low level I\/O system operations or can be easily created from <a href=\"https:\/\/en.wikipedia.org\/wiki\/JavaScript\">JavaScript<\/a>.<\/p>\n<p>Fancy things you can do:<\/p>\n<ul>\n<li>Create readable\/writable streams mapping different operations<\/li>\n<li>Read\/write data from\/to the streams<\/li>\n<li><a href=\"https:\/\/streams.spec.whatwg.org\/#pipe-chains\">Pipe<\/a> data between different streams<\/li>\n<li>Handle <a href=\"https:\/\/streams.spec.whatwg.org\/#pipe-chains\">backpressure<\/a> (controlling the data flow) automagically<\/li>\n<li>Handle <a href=\"https:\/\/streams.spec.whatwg.org\/#queuing-strategies\">chunks<\/a> as the web application sees fit, including different data types<\/li>\n<li>Implement custom loaders to feed different HTML tags (images, multimedia, etc.)<\/li>\n<li>Map some existing APIs to Streams. <a href=\"http:\/\/www.w3.org\/TR\/XMLHttpRequest\/\">XMLHttpRequest<\/a> would be a wonderful first step.<\/li>\n<\/ul>\n<p>First thing we did after the prototype was defining a roadmap:<\/p>\n<ul>\n<li>General <a href=\"https:\/\/streams.spec.whatwg.org\/#rs\">ReadableStream<\/a> that you can create at JavaScript and read from it<\/li>\n<li>XMLHttpRequest integration<\/li>\n<li>Loaders for some HTML tags<\/li>\n<li><a href=\"https:\/\/streams.spec.whatwg.org\/#ws\">WritableStream<\/a><\/li>\n<li>Piping operations<\/li>\n<\/ul>\n<p>As you can see in <a href=\"https:\/\/bugs.webkit.org\/show_bug.cgi?id=138967\">bugzilla<\/a> we are close to finishing the first point, which took quite a lot of effort because it required:<\/p>\n<ul>\n<li>Code cleaning<\/li>\n<li>Making it build in debug<\/li>\n<li>Improving the tests<\/li>\n<li>Writing the <a href=\"http:\/\/www.html5rocks.com\/en\/tutorials\/es6\/promises\/\">promises<\/a> based <a href=\"https:\/\/streams.spec.whatwg.org\/#rs-constructor\">constructor<\/a><\/li>\n<li>Fixing a lot of bugs<\/li>\n<\/ul>\n<p>Of course we didn&#8217;t do all this at the hackfest, only Chuck Norris would have been able to do that. The hackfest provided the oportunity of meeting Youenn in person, working side by side and discussing different problems and possible strategies to solve them, like for example, the error management, queueing chunks and handling their size, etc. which are not trivial given the complexity created by the flexibility of the API.<\/p>\n<p>After the hackfest we continued working and, as I said before, the result you can find at <a href=\"https:\/\/bugs.webkit.org\/show_bug.cgi?id=138967\">bugzilla<\/a>. We hope to be able to land this soon and continue working on the topic within the current roadmap.<\/p>\n<p>To close the topic about the hackfest, it was a pleasure to work with such amount of awesome web engines hackers and I would like to finish thanking the sponsors <a href=\"http:\/\/www.collabora.co.uk\">Collabora<\/a> and <a href=\"http:\/\/www.adobe.com\">Adobe<\/a> and specially my employer, <a href=\"http:\/\/www.igalia.com\">Igalia<\/a>, that was sponsor and host.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/blogs.igalia.com\/jfernandez\/files\/2014\/12\/sponsors.png\" width=\"480\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Yes, I know, I should have written this post before you know, blah, blah, excuse 1, blah, excuse 2, etc. \ud83d\ude09 First of course I would like to thank Igalia for allowing me to use the company time to attend &hellip; <a href=\"https:\/\/blogs.igalia.com\/xrcalvar\/2015\/01\/07\/streams-api-in-webkit-at-the-web-engines-hackfest\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":35,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8,9,43,44,11,6],"tags":[47,45,17,46,41],"class_list":["post-452","post","type-post","status-publish","format-standard","hentry","category-igaliacom","category-planet-gpul","category-planet-igalia","category-planet-webkit","category-planet-webkitgtk","category-planeta-gnome-hispano","category-planets","tag-canon","tag-hackfest","tag-igalia","tag-streams","tag-webkit"],"_links":{"self":[{"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/posts\/452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/comments?post=452"}],"version-history":[{"count":18,"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/posts\/452\/revisions"}],"predecessor-version":[{"id":642,"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/posts\/452\/revisions\/642"}],"wp:attachment":[{"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/media?parent=452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/categories?post=452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.igalia.com\/xrcalvar\/wp-json\/wp\/v2\/tags?post=452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}