Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当预先加载3个以上的数据时,会出现问题 #19

Closed
markogu opened this issue Mar 23, 2021 · 5 comments
Closed

当预先加载3个以上的数据时,会出现问题 #19

markogu opened this issue Mar 23, 2021 · 5 comments

Comments

@markogu
Copy link

markogu commented Mar 23, 2021

在testVC中添加这段代码。

  • (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    for (int i = 0; i<5; i++) {
    LiveGiftShowModel * model = [LiveGiftShowModel giftModel:self.giftArr[i] userModel:self.firstUser];
    model.toNumber = 10;
    model.interval = 0.15;
    [self.customGiftShow animatedWithGiftModel:model];
    }
    }

预加载礼物,3个以内是没问题的,3个以上的话,如果使用的是animatedWithGiftModel的话,后面加入的数字会一直累加(我发现是加载3个以上时toNumber会变成一个很大的值)

@Jonhory
Copy link
Owner

Jonhory commented Mar 23, 2021

该问题已确认。正在修复中~

短时间内需要上线的话建议预先加载最大数量=live_maxGiftShowCount,或者尝试每次animatedWithGiftModel之后延迟一段时间再触发下一次。

@Jonhory
Copy link
Owner

Jonhory commented Mar 24, 2021

执行for循环时,animatedWithGiftModel 第4、5个礼物会跳过showCount >= live_maxGiftShowCount的限制,进入启动定时器流程,在定时器内部会循环执行[weakSelf addLiveGiftShowModel:showModel];,该方法会不断触发[self addToQueue:showModel];,接着会不断地执行以下代码:

        if ([oldKey isEqualToString:key]) {
            oldNumber = oldModel.toNumber;
            showModel.toNumber += oldNumber;
            [self.waitQueueArr removeObject:oldModel];
            break;
        }

从而导致在等待队列中的某个礼物真正执行时,它的toNumber会异常。

@markogu
Copy link
Author

markogu commented Mar 24, 2021

好的,希望作者有时间的时候解决一下这个问题。

@Jonhory
Copy link
Owner

Jonhory commented Mar 25, 2021

以下代码需调整

 if ([oldKey isEqualToString:key]) {
 	oldNumber = oldModel.toNumber;
 	showModel.toNumber += oldNumber;
 	[self.waitQueueArr removeObject:oldModel];
 	break;
 }

修改为:

 if ([oldKey isEqualToString:key] && oldModel.animatedTimer == nil) {
 	oldNumber = oldModel.toNumber;
 	showModel.toNumber += oldNumber;
 	[self.waitQueueArr removeObject:oldModel];
 	break;
 }

已经过个人测试。期待开发者在实际应用场景中的反馈。

@markogu
Copy link
Author

markogu commented Mar 29, 2021

谢谢,暂时没发现有啥问题。

@markogu markogu closed this as completed Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants