Image source update in JavaScript with Opera
Asked Answered
C

2

2

I am loading remote images periodically with an Image object to be later drawn on a canvas. The Image object is created in JS only, it doesn't exist in DOM.

The code is working fine with Chrome and Firefox. In Opera the problem is that the browser seems to always switch to "loading mode" whenever image source is modified, i.e. the cursor changes to the "waiting" one and Opera adds "Elements: X/Y" to the address bar.

Here's the testing code: http://jsfiddle.net/nZntU/3/

Does anyone know any workaround for this Opera behavior?

Cumquat answered 24/7, 2012 at 21:33 Comment(6)
So the problem is just the cursor? I don't use Opera, but have you tried using CSS? cursor: default;Angle
When you change the src of an Image object it's supposed to load the new image immediately. If you don't want it to load immediately, don't set it. Or as @MattBall said, if you're concerned only with the cursor...Palestine
It's not only about the cursor. Opera also puts "Elements X/Y" in the address bar whenever it downloads the new image.Cumquat
@tkone: I know that it loads the image immediately. I want it to do that. I just don't want to disrupt the user with cursor and status bar flickering.Cumquat
Try retrieving the image via an XHR call in base64 and using a data URL to display it? That sounds like an Opera UI thing.Palestine
@tkone: Thanks, I've came across such a solution. But firstly I'd rather be sure there is no other way as performance is important in my app. Doing base64 encoding/decoding doesn't seem like a good idea to me.Cumquat
C
1

As @graste pointed out, Opera 12.50 has this bug fixed. From their change log:

CORE-43199 Opera should not show loading indication for images not in the DOM

Cumquat answered 30/8, 2012 at 9:39 Comment(0)
D
1

I'm using Opera and know what you're describing (or trying to achieve). I set my progress bar placement to "Pop-up at bottom". Your example leads to a popup at the bottom of my browser every second when I've got that tab active and while I'm typing this (while your example is active in a background tab) my cursor switches every second to a progress indicator icon.

The Opera default behaviour is to display the any progress information within the address bar. Even if I disable the progress bar completely (set to "Off") I notice the reloading via a changing reload/stop button in the navigation bar and by a short flickering within the address bar (the bookmark star disappears). There are probably other visible things in different designs/layouts/configurations.

To be honest, you are trying to prevent users from something they may want to see deliberately. I'm often a bit annoyed by such appearing toolbars and wait cursors, but am OTOH usually happy to notice that my browser does stuff in the background. I'm even often confused when using other browsers like Chrome where I don't notice when my browser does heavy AJAX lifting in the background while I'm just reading an article etc. which sometimes leads to confusing situations or weird client side state.

I think you should not try to change the browser behaviour as this is completely out of your scope. There are people out there with heavily customized browsers, chromeless window managers etc.. You're also not trying to enable or change other features in a user's browser when it is not configured to your liking (think 3rd party cookies, javascript, plugins etc.). The user uses and configures his user agent the way he likes it (which means he can disable CSS, use heavy user stylesheets and javascripts, disable iframes, disable moving of windows etc. pp.).

As a side note I remember having read something about a change on this default behaviour in upcoming versions of Opera (regarding XHR), but am not sure about this anymore, as I'm typing this in a development snapshot and still have that default progress bar behaviour. I guess, that's life. :-)

Deprived answered 24/7, 2012 at 22:6 Comment(3)
Thanks for insightful comment regarding this Opera behavior! However, I would have to disagree as to whether this is what I want - taking into account that more and more sites do something dynamically in the background. In my case, I have no other option - I need to fetch c.a. 25 images per second. I guess no user wants to see the waiting cursor that many times ;-)Cumquat
There may be hope for you: CORE-43199 Opera should not show loading indication for images not in the DOM my.opera.com/desktopteam/blog/2012/08/03/summer-core-updateDeprived
Thanks! I will definetely check this out.Cumquat
C
1

As @graste pointed out, Opera 12.50 has this bug fixed. From their change log:

CORE-43199 Opera should not show loading indication for images not in the DOM

Cumquat answered 30/8, 2012 at 9:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.