2013-04-11 48 views
4

我需要在Spotify应用中使用轮换。为此,我使用以下CSS:使用Spotify中CSS循环的高CPU占用率

<!DOCTYPE html> 
<html> 
<head> 
    <style type="text/css"> 
    @-webkit-keyframes rotate { 
     from { 
     -webkit-transform: rotate(0deg); 
     } 

     to { 
     -webkit-transform: rotate(360deg); 
     } 
    } 

    #entity { 
     background-color: #000; 
     width: 200px; 
     height: 200px; 
     -webkit-animation: rotate 3s infinite linear; 
    } 
    </style> 
</head> 
<body> 
    <div id="entity"></div> 
</body> 
</html> 

在Chrome(26.0.1410.43)中,CPU使用率(〜3%)没有大的变化。但是在Spotify 0.8.8.459.g4430eae7中,我得到的CPU占用率在50%到100%之间。除了这段代码,Spotify的原生负载跳动还会发生同样的情况。我的电脑是MacBook Pro 2.5 GHz Intel Core i5,8 GB 1600 Mhz DDR3主内存,Mac OS 10.8.1。我如何以较少的CPU使用率来实现这种旋转?

+0

Spotify在内部不使用Chrome。可能会使用一些自定义的其他Webkit实现,这不像Chrome那样。 – TheHippo 2013-04-29 13:38:55

回答

4

铬的Spotify的版本不支持硬件加速可言,因此CSS转换一样,会招致非常大量的开销。