cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.28k stars 7.05k forks source link

[BUG] PageView - scroll jumps glitch from the end #18616

Open Volodymyr-13 opened 6 years ago

Volodymyr-13 commented 6 years ago
  1. Use this code for UIPageViewTest:

    // Create the page view
    Size pageViewSize(209.1, 70.0);
    Size pageSize(26, 26);
    
    PageView* pageView = PageView::create();
    pageView->setDirection(PageView::Direction::HORIZONTAL);
    pageView->setContentSize(pageViewSize);        
    pageView->setBounceEnabled(true);
    Size backgroundSize = background->getContentSize();
    pageView->setPosition((widgetSize - pageView->getContentSize()) / 2.0f);
    pageView->setItemsMargin(35);
    pageView->removeAllItems();
    pageView->setGlobalZOrder(200);
    
    for (int i = 1; i < 10; ++i)
    {
        Layout* layout = Layout::create();
        layout->setContentSize(pageSize);
        ImageView* imageView = ImageView::create("cocosui/scrollviewbg.png");
        imageView->setScale9Enabled(true);
        imageView->setContentSize(pageSize);
        imageView->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
        layout->addChild(imageView);
        Text* label = Text::create(StringUtils::format("page %d",(i)), "fonts/Marker Felt.ttf", 15);
        label->setColor(Color3B(192, 192, 192));
        label->setPosition(Vec2(layout->getContentSize().width / 2.0f, layout->getContentSize().height / 2.0f));
        layout->addChild(label);
        pageView->addPage(layout);
    }
    pageView->scrollToItem(4);
  2. Scroll till the end of the list and it jumps! Somewhere in the middle of the list of items:

giphy

Volodymyr-13 commented 6 years ago

@drelaptop maybe you can help and push it to fix :) ? First time I've reported about this here http://discuss.cocos2d-x.org/t/pageview-how-to-use/40474/28?u=kamikaze but no attention to this.

drelaptop commented 6 years ago

got this bug, I will test it using the code you give. and look into it, make a feedback for you in days

drelaptop commented 6 years ago

You forget to say, to reproduce this bug we need to modify UIPageView.cpp, refer to the discuss page, modify like:

void PageView::remedyLayoutParameter(Widget *item)
{
    if(!isPreventResize){
        item->setContentSize(this->getContentSize());
    }
    ListView::remedyLayoutParameter(item);
}

I can't find the main logic wrong anywhere, not any difference when debug. see your discuss in detail, this bug is related to the size of PageView. so I tested different sizes, change the pageViewSize from (209.1, 70.0) to (209, 70.0), (209.3, 70.0), (220, 70.0), even (117.7, 70). Bug occurs only when (209.1, 70.0) and (209.3, 70.0) .

suggest you change another size such as (209,70) to use for now. @KAMIKAZEUA I will keep focus on this issue.

Volodymyr-13 commented 6 years ago

Actually I'm using (210,70) for one PageView and got not problems(however, not sure if it will work and all resolutions screen sizes, will it be not depends on this?).

And yes, it depends on a size in this case, but something else too, like ItemsMargin I think. But I have another PageView with with (210, 120) and it has this bug..

Isn't it feels like somewhere there ListView or ScrollView has an awkward code inside or really not tested well?(But anyway such this dependence is really bad.. code design of the component).

I think these components should be rewritten from scratch..

drelaptop commented 6 years ago

yep, this dependence is really bad. I think the original design didn't consider this way that you prevent the resize and make more than one page item into one page.so it's works well at that time, but not works well after your custom.

You can find this bug and fix it for this feature you want. as for rewriting these components, AFAIK cocos2d-x team have no plan in recent months, might do it in the future.

Volodymyr-13 commented 6 years ago

@minggo any comments?

minggo commented 6 years ago

@drelaptop takes charge of UI now, after he is more familiar with UI system, he can do refactor.

Volodymyr-13 commented 6 years ago

And why if @drelaptop takes charge of UI now, he seemed to be offering me to fix this bug by myself? That UI system design is very bad by the way.. when using it I'm always struggle with something.. but no other options for now.. Anyway, I reported this bug, now it's not possible to use PageView in games with this engine, this bug is a nightmare and I can’t use page view at all, because if that. That’s blocker for my game. What is sad, that more I'm reporting bugs or problems like mostly on the forum - it's been ignored.

Volodymyr-13 commented 6 years ago

You forget to say, to reproduce this bug we need to modify UIPageView.cpp, refer to the discuss page

@drelaptop Actually I've tested this on cocos2d-x without making changes to it sources. I only changed UIPageViewTest code.

tiagomartines11 commented 6 years ago

@KAMIKAZEUA Can you please check this pull request #18650

Volodymyr-13 commented 6 years ago

@tiagomartines11 Thanks for sharing. It worked as well for one scroll in my game, but for other pageView with different options - not ideally. I've same scroll as firstly provided code, but with added new size and time:

Size pageSize(17.5, 50);
...
pageView->setScrollDuration(0.1);

Problem - from left side it's bounces fast like it should - 0.1ms, but from right side - it's very slow, like 0.5ms. Here is result:

giphy

And in my actual game it's like even worse, like takes 1 sec for bounce from glue..

Volodymyr-13 commented 6 years ago

@drelaptop @tiagomartines11 any news :) as you see from right part scroll has wrong duration - it's very slow, but should be 0.1sec, like from left side. Specially in my game, for special size list it's even more.. looks very weird..

Volodymyr-13 commented 6 years ago

@drelaptop @minggo @slackmoehrle Is anyone checked this bug? It's still jumps and fix from this pull request only partially fixes this issue - time of bouncing is varying from left and right. As I pointed before in my previous posts.

slackmoehrle commented 6 years ago

The engineering team will get to this when they can. Right now they are focused on 3.17 release.

Volodymyr-13 commented 6 years ago

Release 3.17 with less number of bugs should be like a good idea, right?

slackmoehrle commented 6 years ago

@KAMIKAZEUA please refrain from the rhetorical comments. It pollutes the issue. This bug will be fixed when it makes it into the engineering schedule.

Volodymyr-13 commented 6 years ago

Engineering using milestones, is this bug added into 3.17?

slackmoehrle commented 6 years ago

Not to my knowledge.

drelaptop commented 6 years ago

@KAMIKAZEUA I know this is a urgent issue for you, and it should be fixed, all the bugs should be fixed, it's quite hard to fix so much in one version. I will try to solve it after recent works finished.

Volodymyr-13 commented 6 years ago

@drelaptop It's actually urgent for any game or programmer who's using scroll or page view.

Volodymyr-13 commented 6 years ago

I bet that 1 year will pass and this error will not be fixed. Issue was created Jan 9, so it's almost 8 months already passed.

@walzer @dabingnn @fusijie @linshun @pandamicro @zilongshanren

Do you seriously think that with such a dynamics this engine will survive? It's already dead as I see and as well as many other see this and already leaved it.

So please accept that and just give an official info like - we no longer support this engine and bla bla bla. Don't lie to people.

I was banned on cocos2d-x forum because I asked this, the same question and said the same thoughts. What a shame. I'm just telling the truth.

slackmoehrle commented 6 years ago

@KAMIKAZEUA you were banned on our forums because you don't contribute productively. You spread FUD and don't stop when asked.

Please refrain from doing the same to our GitHub issues. This clouds the issue and makes it harder to sort out work to be done versus noise that causes confusion.

Our engineering team prioritizes bugs and they will complete this work when it comes up, currently v3.18 (See above, please). We also welcome pull requests if you want to fix this yourself so your SpriteBuilder X product works better.

Volodymyr-13 commented 5 years ago

https://github.com/cocos2d/cocos2d-x/issues/18616#issuecomment-406580281

🎁 Happy birthday Bug, 1 year old. Sadly.