Opened 10 years ago

Closed 10 years ago

#9753 closed defect (fixed)

autoStart dojox.image.SlideShow skips 2 images

Reported by: Johnathon Harris Owned by: Shane O'Sullivan
Priority: high Milestone: 1.4
Component: Dojox Version: 1.3.2
Keywords: SlideShow Cc:
Blocked By: Blocking:

Description

Symptom is a slideshow which jumps 2 images on each refresh.

Setup is an autoStart slideshow which loads images via a json datastore.

I have debugged this and it goes down the code path at initialisation which was added in ticket 6857. That fixed the autoStart behaviour when the image store was not yet initialised, as far as I can see.

I believe ticket 8611 causes problems with that code (in my situation) by immediately publishing to the subscribed topic. This is already published to when the image becomes ready, resulting in two publishes and a double image load.

I can see from 8611 that that scenario was fixed by publishing immediately to the new subscription topic. The fact the author could not see why that code was in a subscribe ('I have no idea why this code is wrapped in a "subscribe()".') suggests that their code modification may not be the wisest way to fix that problem.

I can restore correct behaviour for my scenario by backing out the 8611 code change anyway. I have not attached a patch but can do so if needed.

The problem I get occurs as follows:

  • Client code initialises slideshow widget programatically with autoStart:true.
  • Client code calls setDatastore on the new slideshow widget.
    • _complete function in setDatastore calls showImage for index 0.
      • invoked showImage finds images[] not yet loaded and invokes loadImage with callback to showImage.
    • _complete function in setDatastore checks autoStart and calls toggleSlideshow.
      • toggleSlideshow finds images[] not yet loaded and sets up subscription to getShowTopicName (code from ticket 6857), then immediately publishes to it (code from ticket 8611).
        • showNextImage now queued up for invocation at next interval thanks to getShowTopicName subscribed function.
    • Meanwhile the loadImage async fetch from the datastore has just completed and executes the loadIt function, which has the callback to showImage as setup by _complete.
      • The showImage call executes showOrLoadIt function, which contains onEnd function which publishes to getShowTopicName to inform others the image has now been shown.
        • showNextImage now queued up for invocation at next interval thanks to getShowTopicName subscribed function - we now have duplicate events being published.

So it appears the original code in 6857 solved that bug by subscribing to the 'show' topic so it can start the slideshow only when the first image has finished loading. In this scenario it doesn't make sense to immediately publish to the topic as is done in 8611.

Suggest the 8611 change is backed out and that scenario checked more thoroughly for a workaround that doesn't affect this scenario. Obviously the maintainers are more familiar with the code than me and may have better suggestions.

Change History (6)

comment:1 Changed 10 years ago by Johnathon Harris

Sorry, screwed up Trac WikiFormatting in the opening steps in my debug findings. Should be:

  • Client code initialises slideshow widget programatically with autoStart:true.
  • Client code calls setDatastore on the new slideshow widget.
    • (rest as above)

comment:2 Changed 10 years ago by Adam Peller

Owner: changed from Adam Peller to dante

comment:3 Changed 10 years ago by dante

Owner: changed from dante to Shane O'Sullivan

comment:4 Changed 10 years ago by Shane O'Sullivan

Status: newassigned

Changes checked in [20285] should resolve this. If not reported otherwise, this ticket will be closed in the coming weeks

comment:5 Changed 10 years ago by dante

Milestone: tbd1.4

setting version

comment:6 Changed 10 years ago by Shane O'Sullivan

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.