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

Add ability to play animations on a separate instance #7919

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mentholyspirit
Copy link
Contributor

@mentholyspirit mentholyspirit commented Jun 12, 2024

related to #7622

Copy link

google-cla bot commented Jun 12, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@pixelflinger
Copy link
Collaborator

@mentholyspirit could sigh the CLA so we could submit the change eventually?

@pixelflinger pixelflinger added the internal Issue/PR does not affect clients label Jun 13, 2024
@mentholyspirit mentholyspirit force-pushed the feature/reusable-animation branch 2 times, most recently from 0975047 to 8f617eb Compare June 15, 2024 15:02
@mentholyspirit
Copy link
Contributor Author

Signed the CLA

Copy link
Collaborator

@pixelflinger pixelflinger left a comment

Choose a reason for hiding this comment

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

new ctor should not be inline and should be clearly documented.
lifetime management of the Animator on the java side seems sketchy to me, I'll defer to @romainguy here.

Comment on lines 115 to 119
public:
Animator(FilamentAsset *asset, FilamentInstance *instance) : Animator(reinterpret_cast<FFilamentAsset*>(asset), reinterpret_cast<FFilamentInstance*>(instance))
{
}
~Animator();
Copy link
Collaborator

Choose a reason for hiding this comment

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

move this to the existing public section and do not inline the implementation. You also need to document what this ctor does, how to use it and explain that in this case the caller must delete it. You also need to explain the expected lifetime of the asset and the instance with respect to the lifetime of the Animator.

Because this constructor will be confusing you must explain in the documentation that the normal way of getting an Animator is to call FilamentInstance::getAnimator() and that this new ctor is for a specific use case.

Documentation is everything here.

Comment on lines +51 to +62
@Override
public void finalize() {
try {
super.finalize();
} catch (Throwable t) { // Ignore
} finally {
if (mIsOwner) {
nDestroyAnimator(mNativeObject);
mNativeObject = 0;
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like this -- I think we can't rely on finalizers from being called. I'm not sure what the correct pattern would be here. @romainguy what do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Finalizers are unfortunately not reliable (and at best take a lot of time to be invoked). We did use them in a couple of places but it's better to have a manual destroy().

@@ -37,11 +37,30 @@
*/
public class Animator {
private long mNativeObject;
private Boolean mIsOwner = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be lower case boolean, otherwise it's an object.

Comment on lines +51 to +62
@Override
public void finalize() {
try {
super.finalize();
} catch (Throwable t) { // Ignore
} finally {
if (mIsOwner) {
nDestroyAnimator(mNativeObject);
mNativeObject = 0;
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Finalizers are unfortunately not reliable (and at best take a lot of time to be invoked). We did use them in a couple of places but it's better to have a manual destroy().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Issue/PR does not affect clients
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants