-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pieces flickers on update #52
Comments
I'm experiencing the same, but haven't had a chance to dive into it yet. Interestingly, the examples on http://chessboardjs.com seem to work fine, but my implementation flickers. The only difference is that I have specified paths to the assets. Going to try to find some time to research this further within the next week. Doesn't flicker in Firefox, only Chrome and Safari. |
@sesse - can you make a video of this happening? |
Sure; see http://storage.sesse.net/chessboardjs-flicker.avi. You can see it flickers a few times there (although not every time). |
Did a big of debugging. The really odd bit is that I can reproduce it locally, but don't see it at all on the examples on chessboardjs.com. Just tried running it through a Node Express server in case Chrome's file:// was at fault, but still flickers. Here's my small test code: https://github.com/bs/jschesstest @oakmac, can you try running that code locally and see if you can reproduce? I've chased it down to the drawPositionInstant method when called from doAnimations. |
I may have found a solution, see #55 |
@Zolmeister Doesn't fix. |
This seems to be a Node/Express issue for me. Running my test via python -m SimpleHTTPServer is silky smooth. |
My guess is that the entire thing with the web server (be it Node.js, local serving or whatever) is pretty much incidental; there are no HTTP requests going on during a move, even though you could maybe imagine something odd with different HTTP headers. A JavaScript library shouldn't be flicker no matter what server originally served its assets anyway, though. |
I was most definitely recording an HTTP request during an animation, what may be happening is the 'Expires' cache header may not be set for the basic Express server. Here on line 654: function buildPiece(piece, hidden, id) {
var html = '<img src="' + buildPieceImgSrc(piece) + '" ';
if (id && typeof id === 'string') {
html += 'id="' + id + '" ';
}
html += 'alt="" ' +
'class="' + CSS.piece + '" ' +
'data-piece="' + piece + '" ' +
'style="width: ' + SQUARE_SIZE + 'px;' +
'height: ' + SQUARE_SIZE + 'px;';
if (hidden === true) {
html += 'display:none;';
}
html += '" />';
return html;
} |
Setting the Expires header fixed it in Express for me. Still, is proper request caching needed here? The buildPiece method is being called once for every piece on the board whenever a move occurs. Is there a reason each HTML chunk isn't build once and cached? |
The webserver sending appropriate expires headers and returning HTTP 304 Not Modified is probably the solution here (at least for now). I might change the way this works in the future. |
Even with HTTP 304 header you still get flickering (which is why I implemented #55). |
Hi, The solution in #55 still flickers for me (judging from http://queens.zolmeister.com/), just as much as the normal chessboard.js does. And there is not a single HTTP request going on, so really, all this talk about Expires and 304 is not the full story. |
Indeed, but I think #55 highlights the root of the problem, which is that the way animations are written, a new piece is generated and added (i.e. a new |
On Fri, Nov 29, 2013 at 02:01:04AM -0800, Zoli Kahan wrote:
That sounds much more likely, yes. If possible, /* Steinar */Homepage: http://www.sesse.net/ |
it flickers in chrome, but not in Firefox as far as I can see. (I haven't implemented #55) I'd be keen to have an update that works in chrome too :) Cheers, Ingar Arntzen |
Hi - I have fixed the problem by reprogramming how the visuals are updated. The idea is to avoid flushing the entire board on every move/position update. Instead I calculate the delta between CURRENT_POSITION and new POSITION, and then touch only those squares that need to be touched on every position update. This solves the flickering problem for Chrome it seems - and the solution works both for immediate updates as well as animated. Here are some code snippets
I think that's it. Ingar |
#55 Resolves the problem on Mac OSX / Chrome. cacheImage() must be called after ChessBoard.init(). |
Resolved the constant refresh issue by adding ,"Cache-Control" : "max-age=604800" to headers. |
Future reference for anybody trying to solve this issue using Spring: sping-security is overriding the headers. Add this to your WebMvcConfigurerAdapter: @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/img/**")
.addResourceLocations("classpath:/static/img/")
.setCachePeriod(12);
} |
starting the node server resolved this problem for me. |
Thanks @shaktisd 👍👍 |
Still having this problem sadly, any updates? |
Firefox & Chrome were working fine, the issue only occurred for Safari on Mac and IOS.
|
In a great fit of karma, I've seemingly joined the Chrome team responsible for this, and discovered that there is now a bug that seems possibly related: https://crbug.com/961600 |
@frederikme I'm having the same issue, just for Safari on Mac and iOS. Unfortunately the solution you posted doesn't seem to work for me. Did you make any other changes besides setting |
Hi,
When I do board.position(fen), it would seem the pieces are somehow redrawn; at least they flicker ever so shortly during the move somehow. Especially for the pieces that stand still, maybe this could avoided?
I don't think this has anything to do with my code; it happens on e.g. http://chessboardjs.com/examples#3001 when I switch positions.
I'm using Chrome 31.0.1650.57 on Linux.
The text was updated successfully, but these errors were encountered: