SlideShare a Scribd company logo
1 of 31
I’m @aq
HELLO!
5 facts about @aq
Follow
@catskillsconf
Oct 23-25
Ruby, JS, Go Performance etc
but you can hire me!
The Story of
a Yak Shave
Some node.js options:
not precise or 1:1; poor font handling
node-canvas
almost there, but more geared to GUI
applications
node-webkit
Have the ability to reuse existing code and
knowledge about production
I wanted to see if go was
possible
aka Chromium Embedded Framework
Enter and cef2go
chromium
C & C++ API
cef2go (cgo)
C & C++ API
cef2go
your go app
your js app
Service Request/
Response
chromium
JS Exec/
Response
1 for i := 0; i < 3; i++ {
2 browser := cef.CreateBrowser(browserSettings, url, true)
3 browser.ExecuteJavaScript("console.log('we outchea');", "sup.js", 1)
4 }
5
3 browser.ExecuteJavaScript("console.log('we outchea');", "sup.js", 1)
github.com/paperlesspost/chromefarm
Solve it with AJAX
10 func main() {
12 farm := chromefarm.NewFarm()
14 // This serves the postback.html for the browser to load
15 http.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) {
17 http.ServeFile(res, req, "postback.html")
18 })
19 // this handles the callback from JS/AJAX
20 http.HandleFunc("/callback", func(res http.ResponseWriter, req *http.Request) {
21 message := req.FormValue("message")
22 log.Println("Received message from browser: %s", message)
25 })
26 farm.OnReady(func() {
29 for i := 0; i < 2; i++ {
30 browser := farm.CreateBrowser(url)
31 browser.ExecuteJavaScript(fmt.Sprintf("console.log('sup %d');", i), "eva
32 }
33 })
34 farm.Start(":3000")
36 }
7 <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
8 <script type="text/javascript">
9 $.post('/callback', {message: "I've loaded successfully"}, function(resp) {
10 console.log(resp);
11 });
12 </script>
13 </body>
This has to get MORE awesome
Hmmm
24 extCode := `
25 var cef2go;
26 if (!cef2go) {
27 cef2go = {};
28 }
29 (function() {
30 cef2go.callback = function() {
31 native function callback();
32 return callback.apply(this, arguments);
33 }
34 })();
35 `
36 C.cef_register_extension(CEFString("v8/cef2go"), CEFString(extCode), handler)
C C
cef.callback('myGoCallback', "any", "type", 0, "args", true)
1 // cef.callback('myGoCallback', "any", "type", 0.0, 13, true)
2 cef.RegisterV8Callback("myGoCallback", cef.V8Callback(func(args []*cef.V8Value) {
3 arg0 := args[0].ToString() //=> "any"
4 arg1 := args[1].ToString() //=> "type"
5 arg2 := args[2].ToFloat32() //=> 0.0
6 arg3 := args[3].ToInt32() //=> 13
7 arg4 := args[4].ToBool() //=> true
8 // I'm in go now #yolo
9 }))
10
BUt WHY?!
Or a JS app that takes advantage of Go’s
concurrency + tools
A Go app that makes
use of the browser + JS
I mean the real reason is because its an
epic and beautiful hack.
@aq
quirkey.com
github.com/quirkey
THANKS

More Related Content

What's hot

Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"
EPAM Systems
 
02 Introduction to Javascript
02 Introduction to Javascript02 Introduction to Javascript
02 Introduction to Javascript
crgwbr
 

What's hot (20)

Доклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang MeetupДоклад Антона Поварова "Go in Badoo" с Golang Meetup
Доклад Антона Поварова "Go in Badoo" с Golang Meetup
 
Include
IncludeInclude
Include
 
Async programming on NET
Async programming on NETAsync programming on NET
Async programming on NET
 
非同期javascriptの過去と未来
非同期javascriptの過去と未来非同期javascriptの過去と未来
非同期javascriptの過去と未来
 
Security Challenges in Node.js
Security Challenges in Node.jsSecurity Challenges in Node.js
Security Challenges in Node.js
 
みんなの知らないChrome appsの世界
みんなの知らないChrome appsの世界みんなの知らないChrome appsの世界
みんなの知らないChrome appsの世界
 
Scalable Angular 2 Application Architecture
Scalable Angular 2 Application ArchitectureScalable Angular 2 Application Architecture
Scalable Angular 2 Application Architecture
 
Potential gotchas in making a backbone app
Potential gotchas in making a backbone appPotential gotchas in making a backbone app
Potential gotchas in making a backbone app
 
G*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョンG*なクラウド 雲のかなたに ショートバージョン
G*なクラウド 雲のかなたに ショートバージョン
 
KEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.jsKEYNOTE: Node.js interactive 2017 - The case for node.js
KEYNOTE: Node.js interactive 2017 - The case for node.js
 
Hunting for malicious modules in npm - NodeSummit
Hunting for malicious modules in npm - NodeSummitHunting for malicious modules in npm - NodeSummit
Hunting for malicious modules in npm - NodeSummit
 
Serenity Now
Serenity NowSerenity Now
Serenity Now
 
Gkm referral program
Gkm referral programGkm referral program
Gkm referral program
 
Star bed 2018.07.19
Star bed 2018.07.19Star bed 2018.07.19
Star bed 2018.07.19
 
HTML_HHC
HTML_HHCHTML_HHC
HTML_HHC
 
Puppeteer
PuppeteerPuppeteer
Puppeteer
 
Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"Владимир Мигуро "Дао Node.js"
Владимир Мигуро "Дао Node.js"
 
ActionHeroJS Talk
ActionHeroJS TalkActionHeroJS Talk
ActionHeroJS Talk
 
ReactJS & Material-ui Hello world
ReactJS & Material-ui Hello worldReactJS & Material-ui Hello world
ReactJS & Material-ui Hello world
 
02 Introduction to Javascript
02 Introduction to Javascript02 Introduction to Javascript
02 Introduction to Javascript
 

Similar to Chromium Embedded Framework + Go at Brooklyn JS

Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Provectus
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
[drupalcampatx] Adaptive Images in Responsive Web Design
[drupalcampatx] Adaptive Images in Responsive Web Design[drupalcampatx] Adaptive Images in Responsive Web Design
[drupalcampatx] Adaptive Images in Responsive Web Design
Christopher Schmitt
 
[psuweb] Adaptive Images in Responsive Web Design
[psuweb] Adaptive Images in Responsive Web Design[psuweb] Adaptive Images in Responsive Web Design
[psuweb] Adaptive Images in Responsive Web Design
Christopher Schmitt
 
Appsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaolaAppsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaola
drewz lin
 
[refreshpitt] Adaptive Images in Responsive Web Design
[refreshpitt] Adaptive Images in Responsive Web Design[refreshpitt] Adaptive Images in Responsive Web Design
[refreshpitt] Adaptive Images in Responsive Web Design
Christopher Schmitt
 
Reutov, yunusov, nagibin random numbers take ii
Reutov, yunusov, nagibin   random numbers take iiReutov, yunusov, nagibin   random numbers take ii
Reutov, yunusov, nagibin random numbers take ii
DefconRussia
 

Similar to Chromium Embedded Framework + Go at Brooklyn JS (20)

Living with garbage
Living with garbageLiving with garbage
Living with garbage
 
Living With Garbage
Living With GarbageLiving With Garbage
Living With Garbage
 
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
Living with Garbage by Gregg Donovan at LuceneSolr Revolution 2013
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
 
JavaScript front end performance optimizations
JavaScript front end performance optimizationsJavaScript front end performance optimizations
JavaScript front end performance optimizations
 
huhu
huhuhuhu
huhu
 
Oracle APEX migration to 5.1 - Our experience
Oracle APEX migration to 5.1 - Our experienceOracle APEX migration to 5.1 - Our experience
Oracle APEX migration to 5.1 - Our experience
 
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
Василевский Илья (Fun-box): "автоматизация браузера при помощи PhantomJS"
 
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
[drupalcampatx] Adaptive Images in Responsive Web Design
[drupalcampatx] Adaptive Images in Responsive Web Design[drupalcampatx] Adaptive Images in Responsive Web Design
[drupalcampatx] Adaptive Images in Responsive Web Design
 
Live deployment, ci, drupal
Live deployment, ci, drupalLive deployment, ci, drupal
Live deployment, ci, drupal
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007
 
[psuweb] Adaptive Images in Responsive Web Design
[psuweb] Adaptive Images in Responsive Web Design[psuweb] Adaptive Images in Responsive Web Design
[psuweb] Adaptive Images in Responsive Web Design
 
Appsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaolaAppsec usa2013 js_libinsecurity_stefanodipaola
Appsec usa2013 js_libinsecurity_stefanodipaola
 
[refreshpitt] Adaptive Images in Responsive Web Design
[refreshpitt] Adaptive Images in Responsive Web Design[refreshpitt] Adaptive Images in Responsive Web Design
[refreshpitt] Adaptive Images in Responsive Web Design
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
 
Reutov, yunusov, nagibin random numbers take ii
Reutov, yunusov, nagibin   random numbers take iiReutov, yunusov, nagibin   random numbers take ii
Reutov, yunusov, nagibin random numbers take ii
 

Recently uploaded

75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx
Asmae Rabhi
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Monica Sydney
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
ayvbos
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Monica Sydney
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
gajnagarg
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
JOHNBEBONYAP1
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
pxcywzqs
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptx
galaxypingy
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
ydyuyu
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
ydyuyu
 

Recently uploaded (20)

75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx75539-Cyber Security Challenges PPT.pptx
75539-Cyber Security Challenges PPT.pptx
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.Meaning of On page SEO & its process in detail.
Meaning of On page SEO & its process in detail.
 
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girlsRussian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
Russian Call girls in Abu Dhabi 0508644382 Abu Dhabi Call girls
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
一比一原版(Curtin毕业证书)科廷大学毕业证原件一模一样
 
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
Microsoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck MicrosoftMicrosoft Azure Arc Customer Deck Microsoft
Microsoft Azure Arc Customer Deck Microsoft
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
 
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdfpdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
pdfcoffee.com_business-ethics-q3m7-pdf-free.pdf
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
一比一原版(Offer)康考迪亚大学毕业证学位证靠谱定制
 
PowerDirector Explination Process...pptx
PowerDirector Explination Process...pptxPowerDirector Explination Process...pptx
PowerDirector Explination Process...pptx
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
 
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac RoomVip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
Trump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts SweatshirtTrump Diapers Over Dems t shirts Sweatshirt
Trump Diapers Over Dems t shirts Sweatshirt
 

Chromium Embedded Framework + Go at Brooklyn JS

  • 3.
  • 5.
  • 6. Ruby, JS, Go Performance etc but you can hire me!
  • 7.
  • 8. The Story of a Yak Shave
  • 9.
  • 11. not precise or 1:1; poor font handling node-canvas
  • 12. almost there, but more geared to GUI applications node-webkit
  • 13.
  • 14. Have the ability to reuse existing code and knowledge about production I wanted to see if go was possible
  • 15. aka Chromium Embedded Framework Enter and cef2go
  • 16. chromium C & C++ API cef2go (cgo)
  • 17. C & C++ API cef2go your go app your js app Service Request/ Response chromium JS Exec/ Response
  • 18. 1 for i := 0; i < 3; i++ { 2 browser := cef.CreateBrowser(browserSettings, url, true) 3 browser.ExecuteJavaScript("console.log('we outchea');", "sup.js", 1) 4 } 5
  • 21. 10 func main() { 12 farm := chromefarm.NewFarm() 14 // This serves the postback.html for the browser to load 15 http.HandleFunc("/", func(res http.ResponseWriter, req *http.Request) { 17 http.ServeFile(res, req, "postback.html") 18 }) 19 // this handles the callback from JS/AJAX 20 http.HandleFunc("/callback", func(res http.ResponseWriter, req *http.Request) { 21 message := req.FormValue("message") 22 log.Println("Received message from browser: %s", message) 25 }) 26 farm.OnReady(func() { 29 for i := 0; i < 2; i++ { 30 browser := farm.CreateBrowser(url) 31 browser.ExecuteJavaScript(fmt.Sprintf("console.log('sup %d');", i), "eva 32 } 33 }) 34 farm.Start(":3000") 36 } 7 <script src="http://code.jquery.com/jquery-2.1.4.min.js"></script> 8 <script type="text/javascript"> 9 $.post('/callback', {message: "I've loaded successfully"}, function(resp) { 10 console.log(resp); 11 }); 12 </script> 13 </body>
  • 22. This has to get MORE awesome Hmmm
  • 23. 24 extCode := ` 25 var cef2go; 26 if (!cef2go) { 27 cef2go = {}; 28 } 29 (function() { 30 cef2go.callback = function() { 31 native function callback(); 32 return callback.apply(this, arguments); 33 } 34 })(); 35 ` 36 C.cef_register_extension(CEFString("v8/cef2go"), CEFString(extCode), handler)
  • 24. C C
  • 26. 1 // cef.callback('myGoCallback', "any", "type", 0.0, 13, true) 2 cef.RegisterV8Callback("myGoCallback", cef.V8Callback(func(args []*cef.V8Value) { 3 arg0 := args[0].ToString() //=> "any" 4 arg1 := args[1].ToString() //=> "type" 5 arg2 := args[2].ToFloat32() //=> 0.0 6 arg3 := args[3].ToInt32() //=> 13 7 arg4 := args[4].ToBool() //=> true 8 // I'm in go now #yolo 9 })) 10
  • 27.
  • 29. Or a JS app that takes advantage of Go’s concurrency + tools A Go app that makes use of the browser + JS
  • 30. I mean the real reason is because its an epic and beautiful hack.

Editor's Notes

  1. 1) grew up less then a mile from here which leads me to
  2. 2) KINGSTON now repping the HV and live in a 350 year old house, save the date Oct 23rd: Catskills Conf is coming
  3. 3) Used to be the Chief Taco Officer at Paperless Post, now I'm the Chief Scientist and get to work on things like I'm about to show you
  4. 4) Also been doing JS/Ruby/Go Perfomance and Organization consulting so hire me
  5. 5) I host a weekly podcast about Music, Food and Programming with MRB called Beats, Rye & Types (check out the episode with Jed)
  6. Started with the need to take a JS application that relied on canvas to turn data into images. It's important to note that we actually needed a full browser and not just JS - we needed canvas and a way to get that rendered buffer from canvas
  7. I’m sure there are other options and newer ones since we started this project a year ago.
  8. that damn gopher
  9. I really wanted to figure out a way to do this in Go because I've been writing a lot of Go and wanted to be able to reuse the communication, monitoring and tooling that I had already created.
  10. Explored some existing webkit wrappers but nothing really worked well, until I found Chromium embedded framework (CEF) and cef2go.
  11. cef2go takes advantage of the fact that cef exposes a simple C api/bindings and go has amazing support for embedding utilizing c code through cef2go cef2go was in a sort of bad state, so I spent a bunch of time cleaning it up and getting it working on linux
  12. eventually I got to a place where I could boot up a "browser" and execute JS in it.
  13. The cool thing is that because of Go's concurrency model it took no extra work to just loop and create many browsers. In this case, the idea would be 1-per CPU.
  14. The next part was getting data back from JS into the go process and back to the client of the application. The problem is ExecuteJavascript is async so you can't just get the return value.
  15. The "normal" way to do this was to set up an http server and handle AJAX post calls from the JS. This actually was pretty easy, I combined the cef boot + http setup in a little wrapper. Created a little library to manage this called chromefarm.
  16. It looked something like: Go code JS code
  17. But i knew there had to be SOME way to call directly back to go from JS.
  18. Turns out, through some roundabout ways, you can create JS methods bound to the V8 instance in CEF that are backed by NATIVE methods. Native in this case means a C function that is compiled alongside CEF, but using the magic of CGO that method can actually be backed by a Go function. SO
  19. Creating these native methods was sort of a pain though, so using the property of JS that allows methods to have variable argument arity we can bind a single method as a "native" method that can then call any "registered" method on the go side. In the JS this looks like: cef.callback('myGoCallback', "any", "type", 0, "args", true)
  20. And on the go side we just have to register what we want to do with this callback: we also have to translate the individual types to the native types we want in Go. But this actually works, and means we can pass data back and forth from a running browser to Go.
  21. For us it enabled a really stable and fast platform for turning canvas based renders into images. This is running in production today and has already handled requests in the 100s of millions
  22. But ton's of possibilities, it could bring the power of anything you want to do in a modern chrome browser to go and really the other way around, too. You could have an app that's primarily JS but run in a cef shell and have access to all the powerful system level (and concurrent code) that go can provide.