Bug #2580

Async paginators called simultaneously

Added by Anatoly Shcherbinin over 4 years ago. Updated over 4 years ago.

Status:InvalidStart date:03/11/2015
Priority:NormalDue date:
Assignee:Andreas Smas% Done:

0%

Category:Ecmascript & Duktape
Target version:4.10
Found in version:latest build Platform:OS X

Description

If navigate in menu, when async paginator performing on page launch, then another paginator will be started.
This cause duplicates in media list, because simultaneous paginator performed on old offset.


Related issues

Copied to Bug #2946: Async paginators called simultaneously Fixed 03/11/2015

History

#1 Updated by Andreas Smas over 4 years ago

  • Target version set to 4.10

#2 Updated by Andreas Smas over 4 years ago

  • Status changed from New to Need feedback

Can you give an example that doesn't work.

I test with this and it seems ok

var page = require('showtime/page');

new page.Route('asyncPageLoad:test:(.*)', function(page, arg1) {
  var offset = 0;

  function loader() {
    setTimeout(function() {

      for(var i = 0; i < 20; i++) {
        page.appendItem('asyncPageLoad:item:' + (offset + i), "directory", {
          title: "Item" + (offset + i)
        });
      }
      offset += 20;
      page.haveMore(true);
    }, 5000);

  }

  page.type = "directory";
  page.asyncPaginator = loader;
  loader();
});

#3 Updated by Anatoly Shcherbinin over 4 years ago

var cnt = 10;
function items(page, o, new_offset){
    print("offset "+ o);
    setTimeout(function(){

        for(var i = 0; i < cnt; i++) {
            page.appendItem("https://pp.vk.me/c540402/u134197174/video/l_e86e215a.jpg", 'video', {
                            title:"Item " + (o + i),
                            icon:"https://pp.vk.me/c540402/u134197174/video/l_e86e215a.jpg",
                            description:"descriptions",
                            duration:500
                        });
        }
        new_offset(cnt + o);
    }, 750);
}

new page.Route('asyncPageLoad:test:(.*)', function(page, arg1) {
    var offset = 0;
    page.type = "directory";
    page.contents = 'movies';
    (page.asyncPaginator = function loader() {
        page.loading = true;
        items(page, offset, function(new_offset){
            print("new offset" + new_offset);
            offset = new_offset;
            page.loading = false;
            page.haveMore(true);
        });
    })();
});

Reproduction rate depends from delay.
750 ms gives etv. 50%. Try reload page if repeating items doesn't appear.

Also with item "directory" it's very hard to reproduce this case.

#4 Updated by Andreas Smas over 4 years ago

Sorry but I can't reproduce. Running this typically prints

navigator       [INFO ]: Reloading asyncPageLoad:test:a
cmdline         [DEBUG]: Opening route ^asyncPageLoad:test:(.*)
cmdline         [DEBUG]:   Page argument 1 : a
offset 0
cmdline         [ERROR]: Error (32768) at /home/andoma/showtime/src/ecmascript/es_prop.c:226
cmdline         [ERROR]: STACK DUMP: Error: 32768
                             /home/andoma/showtime/src/ecmascript/es_prop.c:226
                             anon  native strict preventsyield
                             anon showtime/prop:30 preventsyield
                             anon showtime/page:274
                             anon test8.js:14 preventsyield
new offset10
offset 10
new offset20
offset 20
new offset30
offset 30
new offset40
offset 40
navigator       [INFO ]: Reloading asyncPageLoad:test:a
cmdline         [DEBUG]: Opening route ^asyncPageLoad:test:(.*)
cmdline         [DEBUG]:   Page argument 1 : a
offset 0
cmdline         [ERROR]: Error (32768) at /home/andoma/showtime/src/ecmascript/es_prop.c:226
cmdline         [ERROR]: STACK DUMP: Error: 32768
                             /home/andoma/showtime/src/ecmascript/es_prop.c:226
                             anon  native strict preventsyield
                             anon showtime/prop:30 preventsyield
                             anon showtime/page:274
                             anon test8.js:14 preventsyield
new offset10
offset 10
new offset20
offset 20
new offset30
offset 30
new offset40
offset 40
new offset50
offset 50
new offset60
offset 60
new offset70
offset 70
new offset80
offset 80
new offset90
navigator       [INFO ]: Reloading asyncPageLoad:test:a
cmdline         [DEBUG]: Opening route ^asyncPageLoad:test:(.*)
cmdline         [DEBUG]:   Page argument 1 : a
offset 0
new offset10
offset 10
new offset20
offset 20
new offset30
offset 30
new offset40
offset 40
new offset50
offset 50
new offset60
offset 60
new offset70
navigator       [INFO ]: Reloading asyncPageLoad:test:a
cmdline         [DEBUG]: Opening route ^asyncPageLoad:test:(.*)
cmdline         [DEBUG]:   Page argument 1 : a
offset 0
new offset10
offset 10
new offset20
offset 20
navigator       [INFO ]: Reloading asyncPageLoad:test:a
cmdline         [DEBUG]: Opening route ^asyncPageLoad:test:(.*)
cmdline         [DEBUG]:   Page argument 1 : a
offset 0
cmdline         [ERROR]: Error (32768) at /home/andoma/showtime/src/ecmascript/es_prop.c:226
cmdline         [ERROR]: STACK DUMP: Error: 32768
                             /home/andoma/showtime/src/ecmascript/es_prop.c:226
                             anon  native strict preventsyield
                             anon showtime/prop:30 preventsyield
                             anon showtime/page:274
                             anon test8.js:14 preventsyield
new offset10
offset 10
new offset20
offset 20
new offset30
offset 30
navigator       [INFO ]: Reloading asyncPageLoad:test:a
cmdline         [DEBUG]: Opening route ^asyncPageLoad:test:(.*)
cmdline         [DEBUG]:   Page argument 1 : a
offset 0
cmdline         [ERROR]: Error (32768) at /home/andoma/showtime/src/ecmascript/es_prop.c:226
cmdline         [ERROR]: STACK DUMP: Error: 32768
                             /home/andoma/showtime/src/ecmascript/es_prop.c:226
                             anon  native strict preventsyield
                             anon showtime/prop:30 preventsyield
                             anon showtime/page:274
                             anon test8.js:14 preventsyield
new offset10
offset 10
new offset20
offset 20
new offset30
offset 30
new offset40
offset 40
new offset50
offset 50
new offset60
offset 60
new offset70

I never see any duplicates, but i'm not 100% sure what to look for.

#5 Updated by Anatoly Shcherbinin over 4 years ago

I have updated movian. Look like in lates version it's already fixed.

#6 Updated by Andreas Smas over 4 years ago

  • Status changed from Need feedback to Invalid

#7 Updated by Anatoly Shcherbinin almost 4 years ago

  • Copied to Bug #2946: Async paginators called simultaneously added

Also available in: Atom PDF