On Sun, Nov 8, 2009 at 10:19 AM, pdknsk <pdk...@googlemail.com> wrote: > So the problem in the original example might be that Chrome does not > resolve the path to get the icon until the document is completely > processed. Both setIcon() are still pending and then set the correct > icons. The first icon is immediately replaced by the second icon and > thus not noticeable. That's just a guess without having a clue how > Chrome works internally, but it seems like a logical explanation.
Yes, that is exactly what is happening internally. When you do chrome.browserAction.setIcon({path: ... }), Chrome must fetch the icon off disk asynchronously. Once the icon is fetched, it is put into a <canvas> element, and then finally the data is drawn. For this reason, if you call setIcon({path:...}) multiple times in the same event, no matter how long execution takes, you'll only ever see the last image. In the case of setIcon({imageData: ... }), the first asynchronous step is skipped, so if you really really want this behavior you can get it by embedding two images in your HTML and using setIcon({imageData:...}) instead of setIcon({path:...}). But stepping back, what are you actually trying to do? Why does foo() take so long to execute? One scenario I can imagine is that foo() contains a synchronous XHR and that the first setIcon() is setting the icon to "loading" and the second is setting it to "logged in". In that case, IMO, the best solution is to not use synchronous XHR. This will allow the first setIcon() call to go through immediately. - a --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Chromium-extensions" group. To post to this group, send email to chromium-extensions@googlegroups.com To unsubscribe from this group, send email to chromium-extensions+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en -~----------~----~----~----~------~----~------~--~---