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

Fix the order of callback by performFunctionInCocosThread and add unit-test for it. #17543

Merged
merged 19 commits into from
Aug 17, 2024

Conversation

dumganhar
Copy link
Contributor

@dumganhar dumganhar commented Aug 15, 2024

Re: #17012, #17464

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

Greptile Summary

This pull request modifies the performInCocosThreadOrder test in native/tests/unit-test/src/scheduler_test.cpp to improve the validation of task execution order in the Scheduler.

  • Updated test to use std::shared_ptr<Scheduler> for better memory management
  • Modified lambda capture to ensure scheduler remains valid throughout task execution
  • Changed result comparison from EXPECT_EQ to EXPECT_TRUE with direct vector comparison
  • Potential thread safety issue introduced, as the shared_ptr is captured by value in the lambda

@dumganhar dumganhar requested a review from minggo August 15, 2024 09:51
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

Interface Check Report

This pull request does not change any public interfaces !

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

[ RUN      ] schedulerTest.performInCocosThreadOrder
unknown file: error: SEH exception with code 0xc0000005 thrown in the test body.
[  FAILED  ] schedulerTest.performInCocosThreadOrder (0 ms)
@dumganhar dumganhar marked this pull request as draft August 16, 2024 03:07
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

25 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Removing all unit tests for path utilities may reduce test coverage. Ensure these tests are either no longer needed or have been moved elsewhere.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Removing all geometry tests may reduce test coverage. Ensure these tests are either replaced or no longer necessary.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Removing all Mat3 unit tests may reduce code coverage and make it harder to catch regressions in future changes to the Mat3 class. Ensure these tests are either relocated or replaced with equivalent tests elsewhere.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Removing all math utility tests may reduce test coverage for critical mathematical operations. Ensure these tests are either relocated or replaced with equivalent tests elsewhere.

@dumganhar dumganhar marked this pull request as ready for review August 17, 2024 04:40
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

26 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

TEST(schedulerTest, performInCocosThreadOrder) {
auto scheduler = std::make_shared<Scheduler>();

std::vector<int> orderResult;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using a thread-safe container for orderResult to prevent potential race conditions

@dumganhar dumganhar merged commit 243ab7e into cocos:v3.8.4 Aug 17, 2024
24 checks passed
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

Successfully merging this pull request may close these issues.

2 participants