Skip to content

player: Remove CreateInstance() from some player classes#9244

Merged
kjyoun merged 6 commits intoyoutube:mainfrom
rakuco:player/remove-CreateInstance
Feb 26, 2026
Merged

player: Remove CreateInstance() from some player classes#9244
kjyoun merged 6 commits intoyoutube:mainfrom
rakuco:player/remove-CreateInstance

Conversation

@rakuco
Copy link
Collaborator

@rakuco rakuco commented Feb 25, 2026

These methods were useful back when thread management was a more manual process and classes like PlayerWorker::CreateInstance() could return nullptr and this had to trickle up the caller hierarchy.

This is no longer the case since PRs like #9027 and #8064, and the constructors can be called directly now.

Fixed: 477798131

These methods were useful back when thread management was a more manual
process and classes like PlayerWorker::CreateInstance() could return nullptr
and this had to trickle up the caller hierarchy.

This is no longer the case since PRs like youtube#9027 and youtube#8064, and the
constructors can be called directly now.

Fixed: 477798131
@github-actions
Copy link
Contributor

🤖 Gemini Suggested Commit Message


media: Remove player CreateInstance methods

Simplify player object creation by removing redundant static factory
methods from SbPlayerPrivateImpl and PlayerWorker classes. Previous
refactorings (PRs 9027 and 8064) streamlined thread management and
eliminated scenarios where these factories could return nullptr.
Direct constructor calls now suffice, simplifying the codebase and
object initialization.

Bug: 477798131

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the player creation logic by removing the static CreateInstance() factory methods from SbPlayerPrivateImpl and PlayerWorker in favor of direct constructor calls. This is a good simplification, as the factory methods are no longer necessary after recent changes to thread management. The changes are well-executed, including the move to initialize worker_ in the member initializer list using std::make_unique and making it a const std::unique_ptr. I have one minor suggestion to improve the clarity of an error message.

@rakuco
Copy link
Collaborator Author

rakuco commented Feb 25, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the player creation logic by removing static CreateInstance() factory methods from SbPlayerPrivateImpl and PlayerWorker classes, opting for direct constructor calls to simplify code and improve clarity with modern C++ practices. However, this change introduces a potential null pointer dereference in starboard/android/shared/player_create.cc by removing a crucial validity check before using the newly created player object. Additionally, important error reporting logic for player creation failures has been removed. While the refactoring is well-motivated, these security and robustness concerns must be addressed, and there's also a suggestion to further align the code with modern C++ best practices.

@rakuco
Copy link
Collaborator Author

rakuco commented Feb 25, 2026

cc @abhijeetk @jkim-julie @Gyuyoung

@rakuco rakuco requested a review from kjyoun February 25, 2026 09:17
Copy link
Contributor

@kjyoun kjyoun left a comment

Choose a reason for hiding this comment

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

Thanks for making this chage.
This is the one that I wanted to make.

I left some style comments.

@rakuco
Copy link
Collaborator Author

rakuco commented Feb 26, 2026

@kjyoun thanks for reviewing this. are you able to merge this PR as well?

@kjyoun kjyoun merged commit 1931288 into youtube:main Feb 26, 2026
616 of 619 checks passed
@kjyoun
Copy link
Contributor

kjyoun commented Feb 26, 2026

Done. thanks for making this change!

@rakuco rakuco deleted the player/remove-CreateInstance branch February 26, 2026 14:28
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