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

Refine: make multi skeleton component shared one instance of spine.Skeleton while spine working at sharedCache mode #16593

Merged
merged 6 commits into from
Dec 18, 2023

Conversation

bofeng-song
Copy link
Contributor

@bofeng-song bofeng-song commented Dec 12, 2023

Re: #
cocos/cocos-engine-external#449
#16598

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.

@bofeng-song bofeng-song requested a review from minggo December 12, 2023 05:54
}

void SpineSkeletonInstance::release() {
--_referenceCount;
Copy link
Contributor

Choose a reason for hiding this comment

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

It is better to assert _referenceCount > 0.

@bofeng-song bofeng-song marked this pull request as draft December 13, 2023 09:02
…eleton while spine working at sharedCache mode
@bofeng-song bofeng-song marked this pull request as ready for review December 14, 2023 06:08
@bofeng-song bofeng-song changed the title fix setAnimation can not work normaly while animation name different with default animation name Refine: make multi skeleton component shared one instance of spine.Skeleton while spine working at sharedCache mode Dec 14, 2023
Copy link

github-actions bot commented Dec 14, 2023

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -52023,8 +52023,9 @@
                 static createSpineSkeletonDataWithJson(jsonStr: string, atlasText: string): SkeletonData;
                 static createSpineSkeletonDataWithBinary(byteSize: number, atlasText: string): SkeletonData;
                 static registerSpineSkeletonDataWithUUID(data: SkeletonData, uuid: string);
                 static destroySpineSkeletonDataWithUUID(uuid: string);
+                static destroySpineSkeleton(skeleton: Skeleton): void;
                 static getCurrentListenerID(): number;
                 static getCurrentEventType(): EventType;
                 static getCurrentTrackEntry(): TrackEntry;
                 static getCurrentEvent(): Event;
@@ -67477,8 +67478,9 @@
             curAnimationCache: _cocos_spine_skeleton_cache__AnimationCache | null;
             animationsCache: {
                 [key: string]: _cocos_spine_skeleton_cache__AnimationCache;
             };
+            assetUUID: string;
         }
         export class _cocos_spine_skeleton_cache__SkeletonCache {
             static readonly FrameTime: number;
             static sharedCache: _cocos_spine_skeleton_cache__SkeletonCache;
@@ -67492,10 +67494,11 @@
             constructor();
             enablePrivateMode(): void;
             clear(): void;
             invalidAnimationCache(uuid: string): void;
-            removeSkeleton(uuid: string): void;
-            getSkeletonCache(uuid: string, skeletonData: sp.spine.SkeletonData): _cocos_spine_skeleton_cache__SkeletonCacheItemInfo;
+            destroySkeleton(assetUuid: string): void;
+            createSkeletonInfo(skeletonAsset: sp.SkeletonData): _cocos_spine_skeleton_cache__SkeletonCacheItemInfo;
+            getSkeletonInfo(skeletonAsset: sp.SkeletonData): null | _cocos_spine_skeleton_cache__SkeletonCacheItemInfo;
             getAnimationCache(uuid: string, animationName: string): null | _cocos_spine_skeleton_cache__AnimationCache;
             initAnimationCache(uuid: string, data: sp.SkeletonData, animationName: string): null | _cocos_spine_skeleton_cache__AnimationCache;
             destroyCachedAnimations(uuid?: string): void;
         }

this._animationPool[`${uuid}#${aniKey}`] = animationCache;
animationCache.clear();
};
const privateOperate = (aniKey: string, animationCache: AnimationCache): void => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it called privateOperate? What does private mean here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

private corresponds to privateCache mode.

let skeletonInfo = this._skeletonCache[uuid];
if (!skeletonInfo) {
const skeleton = null;
const skeleton = new spine.Skeleton(skeletonData);
Copy link
Contributor

Choose a reason for hiding this comment

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

skeleton is forever null in the old code?

Copy link
Contributor Author

@bofeng-song bofeng-song Dec 14, 2023

Choose a reason for hiding this comment

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

skeleton will constructor by skeleton component's _instance in old code

Copy link
Contributor

Choose a reason for hiding this comment

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

So we move the spine.Skeleton construction code to here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, previous logic multi skeleton component can not share the same object of spine.skeleton

@bofeng-song bofeng-song reopened this Dec 15, 2023
@minggo minggo merged commit c2e1abe into cocos:v3.8.2 Dec 18, 2023
23 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.

3 participants