ã¯ããã«
ã»ãšãã©ã®Webéçºè ã«ãšã£ãŠãWebããŒãžã®åºæ¬çãªè¡šçŸã¯DOMã§ãã ãã®è¡šçŸãç»é¢äžã®ç»åã«å€æããããã»ã¹ïŒä»¥éãã¬ã³ããªã³ã°ïŒã¯ãå€ãã®å Žåã誀解ã®ããŒã«ã«èŠãããŠããŸãã è¿å¹Žããã©ãŠã¶éçºè ã¯ãã®ããã»ã¹ãç©æ¥µçã«æé©åããŠãããäžéšã®äœæ¥ãGPUã®è©ã«ç§»ããŠããŸããããã¯ãããŒããŠã§ã¢ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ããšåŒã°ããŠããŸãã Canvas2DãšWebGLãé€ããéåžžã®ããŒãžã®ã³ã³ããã¹ãã§ã®ã¬ã³ããªã³ã°ãèŠãŠãããŸãã ãã®èšäºã§ã¯ãChromeãã©ãŠã¶ãŒã§Webã³ã³ãã³ãç»åãçæããéã«ããŒããŠã§ã¢ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ã䜿çšãããšããåºæ¬çãªæŠå¿µãæããã«ããŸãã
èŠå
ããã§ã¯ãWebKitãšã³ãžã³ã«ã€ããŠã®ã¿èª¬æããChromiumã§ã®ãã©ãŒã¯ã«ã€ããŠããæ£ç¢ºã«èª¬æããŸãã ãã®èšäºã§ã¯ãChromeã§ã®å®è£ ã®è©³çŽ°ã«ã€ããŠèª¬æããŸãããæšæºã«ã¯ææžåãããŠããŸããã ãããã£ãŠããã®èšäºã§èª¬æãããŠãããã®ãä»ã®ãã©ãŠã¶ãŒã«é©çšã§ãããšããä¿èšŒã¯ãããŸããã ãã ãããããã®åŸ®åŠãªç¹ãææ¡ããŠãããšããããã°ã®åŸ®èª¿æŽãšçç£æ§ã®åäžã«åœ¹ç«ã¡ãŸãã
ãŸããChromeã®ã¬ã³ããªã³ã°ãšã³ãžã³ã¯æ¥éã«éçºãããŠããããšã«æ³šæããŠãã ããã ãŸããããã«èšèŒãããŠãããã¹ãŠã6ãæåŸã«åãããšãä¿èšŒãããã®ã§ã¯ãããŸããã
çŸæç¹ã§ã¯ãChromeã¯ããŒããŠã§ã¢ãšå€ããœãããŠã§ã¢ã®2ã€ã®ã¬ã³ããªã³ã°ã¡ã«ããºã ããµããŒãããŠããããšã«æ³šæããŠãã ããã ãã®èšäºã®å·çæç¹ã§ã¯ãWindowsãChromeOSãããã³Androidäžã®Chromeã§ã¯ããã¹ãŠã®ããŒãžãããŒããŠã§ã¢ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ã§ã¬ã³ããªã³ã°ãããŠããŸãã MacOSããã³Linuxã§ã¯ãæ§æèŠçŽ ãå«ãããŒãžã®ã¿ããã®ã¢ãŒãã«åé¡ãããŸãïŒããã«ã€ããŠã¯åŸè¿°ããŸãïŒããããã«ä¿®æ£ãããŸãã
æåŸã«ãã¬ã³ãã©ãŒãšã³ãžã³ã®äžéšã®ã¿ãèŠãŠãçç£æ§ãå€§å¹ ã«åäžãããããã«èšèšããããã®ã«æ³šæãæããŸãã èªåã®ãµã€ãã§ç·Žç¿ããããšã§ãã¬ã€ã€ãŒã¢ãã«ãããããç解ã§ããŸãã ããããããããç¡æèã«çæããªãã§ãã ãããããã«ãããã°ã©ãã£ãã¯ã¹ã¿ãã¯å šäœã«äžèŠãªãªãŒããŒããããè¿œå ãããå¯èœæ§ããããŸãã
DOMããç»é¢ãžã®ãã¹
ã¬ã€ã€ãŒã®æŠå¿µ
ããŒãžããã©ãŠã¶ã«èªã¿èŸŒãŸããŠåŠçããããšã誰ããDOMãšããŠç¥ã£ãŠãããã®ã«å€ãããŸãã ããŒãžã¬ã³ããªã³ã°ããã»ã¹ã¯ãéçºè ãçŽæ¥ã¢ã¯ã»ã¹ã§ããªãäžé£ã®äžéå€æãä»ããŠé²è¡ããŸãã ããã»ã¹ã§çæãããæãéèŠãªæ§é ã¯ãã¬ã€ã€ãŒã§ãã
Chromã®ã¬ã€ã€ãŒã«ã¯ãDOMãµãããªãŒãå«ãRenderLayersãšã以åã®ãµãããªãŒãå«ãGraphicsLayersã®2ã€ã®ã¿ã€ãããããŸãã ã°ã©ãã£ãã¯ã¬ã€ã€ãŒã¯ãã¯ã¹ãã£ãšããŠGPUã«éä¿¡ããããããåŸè ã¯ç§ãã¡ã«ãšã£ãŠããèå³æ·±ããã®ã«ãªããŸããã 以äžããã¬ã€ã€ãŒããšããèšèãçŸãããšããã¯ã©ãã§ããã°ã©ãã£ãã¯ã¬ã€ã€ãŒãæå³ããŸãã
GPUã®çšèªã«ã€ããŠå°ã説æãããã¯ã¹ãã£ãšã¯äœããèããŠã¿ãŸãããã
ã¡ã€ã³ã¡ã¢ãªïŒRAMïŒããã°ã©ãã£ãã¯ããã»ããµïŒVRAMïŒã®ã¡ã¢ãªã«è»¢éãããã°ã©ãã£ãã¯ãªããžã§ã¯ãïŒããããããïŒã®ããããããã®äžéšãšèããŠãã ããã ãã¯ã¹ãã£ãGPUã®æã«èœã¡ããšãããªãŽã³ã¡ãã·ã¥ã«åŒã£åŒµãããšãã§ããŸãããããªã²ãŒã ã§ã¯ããã®ææ³ã䜿çšããŠãã¹ãã³ãã3次å ãªããžã§ã¯ãã«åŒã䌞ã°ããŸãã Chromeã¯ãã¯ã¹ãã£ã䜿çšããŠããŒãžã³ã³ãã³ãã®äžéšãGPUã«è»¢éããŸããããã«ãããåŸã§ããããåçŽãªæ£æ¹åœ¢ã°ãªããã«ãªãŒããŒã¬ã€ãã3次å å€æãè¡ãããšãã§ããŸãã ããã3D CSSã®ä»çµã¿ã§ãããããŒãžã¹ã¯ããŒã«ã®ããã©ãŒãã³ã¹ã«ã倧ããªåœ±é¿ãåãŒããŸããããŸãæåã«èããŸãã
ã¬ã€ã€ãŒã®æŠå¿µãããæ確ã«èª¬æããããã«ãããã€ãã®äŸãèŠãŠã¿ãŸãããã
Chromeã®ã¬ã€ã€ãŒãç解ããããã®éåžžã«äŸ¿å©ãªããŒã«ããããŸã-éçºè ããŒã«ããŒã®èšå®ãŠã£ã³ããŠã®ãã¬ã³ããªã³ã°ãã»ã¯ã·ã§ã³ã«ãããåæã¬ã€ã€ãŒã®å¢çç·ã衚瀺ããªãã·ã§ã³ã ãã®ãªãã·ã§ã³ã¯ãç»é¢äžã®ã¬ã€ã€ãŒã®å¢çç·ããªã¬ã³ãžè²ã§åŒ·èª¿è¡šç€ºããã ãã§ãã ãªã³ã«ããŸãããã ãã®èšäºã®å·çæç¹ã§ã¯ãäŸã®ã¹ã¯ãªãŒã³ã·ã§ããã¯ãã¹ãŠChrome CanaryãChrome 27ã§æ®åœ±ãããŠããŸãã
äŸ1ïŒåå±€ããŒãž
<html> <body> <div>I am a strange root.</div> </body> </html>
ãã®ããŒãžã«ã¯åäžã®ã¬ã€ã€ãŒããããŸãã éãã°ãªããã¯ã¿ã€ã«ã®å¢çãè¡šããŸããããã¯ãChromeã倧ããªã¬ã€ã€ãŒãåå²ããŠGPUã«éä¿¡ããããã«äœ¿çšããã¬ã€ã€ãŒã®éšåã§ãã ä»ã圌ãã¯ç§ãã¡ã«ã¯ããŸãèå³ããããŸããã
äŸ2 ïŒç¬èªã®ã¬ã€ã€ãŒã®èŠçŽ
<html> <body> <div style="-webkit-transform: rotateY(30deg) rotateX(-30deg); width: 200px;"> I am a strange root. </div> </body> </html>
3D CSSããããã£ãå転ããèŠçŽ ã«èšå®ãããšãç¬èªã®ã¬ã€ã€ãŒãå²ãåœãŠãããŠããããšãããããŸããäžã®ã¹ã¯ãªãŒã³ã·ã§ããã§ãªã¬ã³ãžè²ã®ãã¬ãŒã ãã©ããããŠããããšã«æ³šæããŠãã ããã ïŒããã¯ãåã¬ã€ã€ãŒãä»ã®ã¬ã€ã€ãŒãšã¯ç¬ç«ããŠã¬ã³ããªã³ã°ããããã«è¡ãããŸãïŒ
ç©å±€æ¡ä»¶
ç¬èªã®ã¬ã€ã€ãŒãååŸã§ããèŠçŽ ã¯ä»ã«ãããŸããïŒ Chromeã®ãã¥ãŒãªã¹ãã£ãã¯ã¯æè¿ãã®æ¹åã«çºå±ããŠããŸãããçŸæç¹ã§ã¯ã次ã®æ¡ä»¶ã®ãããããã¬ã€ã€ãŒã®äœæã«ã€ãªãããŸãã
- CSSèŠçŽ ã«ã¯3Då€æããããã£ããããŸã
- ãããªã®ãã³ãŒãã«ããŒããŠã§ã¢ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ã䜿çšãã
<video \>
èŠçŽ -
<canvas \>
3DïŒWebGLïŒã³ã³ããã¹ããŸãã¯å é2D㧠- ãµãŒãããŒãã£ã®ãã©ã°ã€ã³ïŒFlashãå«ãïŒ
- éæ床ã®CSSã¢ãã¡ãŒã·ã§ã³ãŸãã¯å€æã®ã¢ãã¡ãŒã·ã§ã³ã䜿çšããèŠçŽ
- ããŒããŠã§ã¢ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ã䜿çšããCSSãã£ã«ã¿ãŒã䜿çšããèŠçŽ
- ã³ã³ããžã·ã§ã³ã¬ã€ã€ãŒãæã€åå«ãæã€èŠçŽ
- èŠçŽ ã«ã¯ãããäœãz-indexãæã€å åŒïŒå§åŠ¹èŠçŽ ïŒããããããèªäœã«ç¬èªã®ã¬ã€ã€ãŒããããŸãïŒã€ãŸããèŠçŽ ãã³ã³ããžã·ã§ã³ã®äžã«ã¬ã³ããªã³ã°ãããå ŽåïŒ
å®çšåïŒã¢ãã¡ãŒã·ã§ã³
CSSå€æãã¢ãã¡ãŒã·ã§ã³åããããšã«ãããèŠçŽ ãç¬èªã®ã¬ã€ã€ãŒã«åé¡ãããããšãããããŸãã ãŸããã¬ã€ã€ãŒã¯ã¢ãã¡ãŒã·ã§ã³ã«éåžžã«é©ããŠããŸãã
äŸ3 ïŒã¢ãã¡ãŒã·ã§ã³åãããã¬ã€ã€ãŒ
<html> <head> <style type="text/css"> div { -webkit-animation-duration: 5s; -webkit-animation-name: slide; -webkit-animation-iteration-count: infinite; -webkit-animation-direction: alternate; width: 200px; height: 200px; margin: 100px; background-color: gray; } @-webkit-keyframes slide { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(120deg); } } </style> </head> <body> <div>I am a strange root.</div> </body> </html>
æãåçŽãªã±ãŒã¹ã§ã¯ãChromeã¯ããã°ã©ã ã§ã¬ã€ã€ãŒã®ã³ã³ãã³ããæç»ãããã¯ã¹ãã£ãšããŠGPUã«éä¿¡ããŸãã ãã®ã³ã³ãã³ããå°æ¥å€æŽãããªãå Žåãåæç»ããå¿ èŠã¯ãããŸããã ããã¯è¯ãããšã§ããåæç»ã«ã¯æéãããããŸããããšãã°ãã¹ã¯ãªããã®äœæã«è²»ããããšãã§ããŸãã ãŸããåæç»ã«æéãããããšããã¬ãŒã ã¬ãŒãã®äœäžãã¢ãã¡ãŒã·ã§ã³ã®é 延ãšãã圢ã§è¿·æãªæ¬ é¥ãçºçããå¯èœæ§ããããŸãã
ã¬ã€ã€ãŒãååŸã«å転ããŠããéãéçºè ããã«ã®ã¿ã€ã ã©ã€ã³ã«åæç»æäœããªãããšã確èªã§ããŸãã
ã泚æ åå¡è£
ãã ããã¬ã€ã€ãŒã®ã³ã³ãã³ããå€æŽããããšãåæç»ãè¡ãããŸãã
äŸ4 ïŒã¬ã€ã€ãŒã®åæç»
<html> <head> <style type="text/css"> div { -webkit-animation-duration: 5s; -webkit-animation-name: slide; -webkit-animation-iteration-count: infinite; -webkit-animation-direction: alternate; width: 200px; height: 200px; margin: 100px; background-color: gray; } @-webkit-keyframes slide { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(120deg); } } </style> </head> <body> <div id="foo">I am a strange root.</div> <input id="paint" type="button" onclick="" value=ârepaintâ> <script> var w = 200; document.getElementById('paint').onclick = function() { document.getElementById('foo').style.width = (w++) + 'px'; } </script> </body> </html>
ãã¿ã³ãæŒããã³ã«ãå転èŠçŽ ãå¹ ã®ãã¯ã»ã«ãè¿œå ããŸãã ããã«ããããšã¬ã¡ã³ãå šäœã®åæç»ãè¡ãããŸãããã®å Žåã¯ãå¥ã®ã¬ã€ã€ãŒã«ãªããŸãã
ããŒãžã®ã©ã®éšåãåæç»ãããŠããããç°¡åã«ç¢ºèªããã«ã¯ãéçºè ããã«ã®èšå®ãŠã£ã³ããŠã®åããã¬ã³ããªã³ã°ãã»ã¯ã·ã§ã³ã§ãshow paint rectsããªãã·ã§ã³ãæå¹ã«ããŸãã ãªã³ã«ããåŸãã¢ãã¡ãŒã·ã§ã³èŠçŽ ãšããŠæ³šæããŠãã ããããã¿ã³ãã¯ãªãã¯ãããšããã¿ã³ãèµ€ãç¹æ» ããŸãã
åæç»ã€ãã³ãã¯ã¿ã€ã ã©ã€ã³ã§ã確èªã§ããŸãã éãç®ã¯ãåæç»ã€ãã³ãã®éè€ã«æ°ä»ãã§ãããã1ã€ã¯ã¬ã€ã€ãŒèªäœã®ããã®ãã®ã§ããã1ã€ã¯ãã¿ã³ã®ç¶æ ã®è¡šç€ºãå€æŽããããã®ãã®ã§ãã
Chromeã¯åžžã«ã¬ã€ã€ãŒãå®å šã«åæç»ãããšã¯éããªãããšã«æ³šæããŠãã ããã DOMãå€æŽãããã¬ã€ã€ãŒïŒéã®å¢çç·ã§ããŒã¯ãããã¿ã€ã«ïŒã®ãã©ã°ã¡ã³ãã®ã¿ãéžæçã«åæç»ããŸãã ãã®äŸã§ã¯ãã¬ã€ã€ãŒå šäœã«1ã€ã®èŠçŽ ãããããŸããããã»ãšãã©ã®å®éã®ãããžã§ã¯ãã§ã¯ãã¬ã€ã€ãŒããšã«ããã«å€ãã®èŠçŽ ããããŸãã
次ã®è³ªåã¯ãDOMãå»æ¢ãããŠåæç»ãããåå ã¯äœã§ããïŒ DOMãç¡å¹ã«ãªãå¯èœæ§ã®ããããã€ãã®æã§ãã¹ãŠã®ã±ãŒã¹ãã«ããŒããããšã¯å°é£ã§ãã ã»ãšãã©ã®å Žåãããã¯CSSã¹ã¿ã€ã«ãå€æŽããå®è¡æã«å¯èŠã³ã³ãã³ããåçã«çæããããšã«ããDOMã®å°ç¡ãã§ãã ãããŒã»ãžã§ã³ãã£ã«ã³ãŒã«ã¯åœŒã®ããã°ã§ãããã説æããã¹ãã€ã¢ã³ã»ã¹ãã€ãããéåžžã«è©³çŽ°ãªèšäºãæžããããç§ãã¡ã話ãããšããŠãããã®æ°ããããšã®è©³çŽ°ãªãã§åæç»ã説æããããšã«éå®ãããŠãã-ãããªãµãã·ã¹ãã ãéããŠåæããã
ãã¹ãŠããŸãšããïŒç»é¢äžã®DOM
ã§ã¯ãChromeã¯ã©ã®ããã«ããŠDOMãç»é¢äžã®ç»åã«å€æããŸããïŒ æŠå¿µçã«ã¯ã次ã®æé ãåºå¥ã§ããŸãã
- äžèšã®åºæºã«åŸã£ãŠãDOMãååŸããã¬ã€ã€ãŒã«åå²ããŸã
- ããã°ã©ã ã§åã¬ã€ã€ãŒãåå¥ã«æç»ããŸã
- GPUããã¯ã¹ãã£ãšããŠéä¿¡ããŸã
- ã°ã©ãã£ãã¯ã¹ãµãã·ã¹ãã ã§ãæçµç»åã®ãã¹ãŠã®ã¬ã€ã€ãŒãã³ã³ãã€ã«ããŸã
ããã¯ãããŒãžã®æåã®ãã¬ãŒã ãæããšãã«èµ·ããããšã§ãã ãã ãã次ã®åãã¬ãŒã ã®ã¬ã³ããªã³ã°ã®ãªãŒããŒããããåæžããæ¹æ³ã¯ããã€ããããŸãã
- ãã¹ãŠã®CSSã¹ã¿ã€ã«ã®å€æŽãåæç»ã«ã€ãªããããã§ã¯ãããŸããã Chomeã¯ãGPUã®ã¡ã¢ãªã«æ¢ã«ããæ¢åã®ã¬ã€ã€ãŒã®ã¿ãåæ§æã§ããŸãã ããã¯ãæ§æããããã£ïŒå€æãéæ床ããã£ã«ã¿ãŒïŒã®ã¿ãå€æŽããããšã§å®çŸã§ããŸãã
- ã¬ã€ã€ãŒã®äžéšãå€æŽããããšãGPUã«ãã£ãŠåæç»ãããåéä¿¡ãããŸãã ã³ã³ãã³ããå€æŽããã«ãæ§æããããã£ïŒå€æãŸãã¯éæ床ïŒã®ã¿ãå€æŽããå ŽåãChromeã¯ãããããããªã¡ã¢ãªã«æ®ããåæ§æããŠæ¬¡ã®ãã¬ãŒã ãçæã§ããŸãã
ç解ããŠããå¿ èŠãããããã«ãã¬ã€ã€ãŒããŒã¹ã®è€åã¢ãã«ã¯ã¬ã³ããªã³ã°ããã©ãŒãã³ã¹ã«å€§ããªå©ç¹ãæäŸããŸãã åæã¯ãå®å šãªåæç»ã«æ¯ã¹ãŠã¬ã³ããªã³ã°ã®å®äŸ¡ãªæ¹æ³ã§ãã ãããã£ãŠãèŠçŽ ã®çµæç¹æ§ã®ã¿ãåŒãåºããŠã¬ã€ã€ãŒã®åæç»ãåé¿ããããšãããšãããã©ãŒãã³ã¹ãæé©åã§ããŸãã å¥å šãªéçºè ã¯ãé©åãªã¿ã€ãã³ã°ã§ã¬ã€ã€ãŒã®äœæã匷å¶ã§ããããã«ãåæãã¢ã¯ãã£ãã«ããããããã£ã®ãªã¹ãã«æ³šæããŸãã ãã ããã¬ã€ã€ãŒã®äœæã«ã¯æ³šæããŠãã ãããããã¯ç¡æã§ã¯ãããŸãããã·ã¹ãã ã¡ã¢ãªãšãããªãµãã·ã¹ãã ã¡ã¢ãªãå¿ èŠã§ãïŒã¢ãã€ã«ããã€ã¹ã§å¶éãããŸãïŒã
ããã ãã§ãïŒ