Skip to content

Commit

Permalink
1.36.9 more atlasURI instrumentation and lock down init owner to spec…
Browse files Browse the repository at this point in the history
…ific instance
  • Loading branch information
MikalDev committed Feb 19, 2021
1 parent 72aef86 commit 6d1d6ba
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
Binary file added dist/Spine-v1.36.9.c3addon
Binary file not shown.
2 changes: 1 addition & 1 deletion src/addon.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "plugin",
"name": "Spine",
"id": "Gritsenko_Spine",
"version": "1.36.8",
"version": "1.36.9",
"author": "Mikal and Igor Gritsenko",
"website": "https://gritsenko.github.io/c3_spine_plugin",
"documentation": "https://gritsenko.github.io/c3_spine_plugin",
Expand Down
23 changes: 15 additions & 8 deletions src/c3runtime/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
{
this.atlasURI = this.atlasPath;
this.jsonURI = this.jsonPath;
console.info('[Spine] loadSkeletonTextures, atlasURI, not preview', this.atlasURI, this.atlasPath, this.objectName, this.runtime.GetTickCount());
console.info('[Spine] loadSkeletonTextures, atlasURI, not preview', this.atlasURI, this.atlasPath, this.uid, this.objectName, this.runtime.GetTickCount());
}

this.sdkType._assetPaths[this.atlasURI] = this.atlasURI;
Expand Down Expand Up @@ -173,12 +173,12 @@

this.sdkType._texturesBatcherInitialized = true;
this.sdkType._texturesBatcherInitializing = false;
console.info('[Spine] loadSkeletonTextures, atlasURI', this.atlasURI, this.atlasPath, this.objectName, this.runtime.GetTickCount());
console.info('[Spine] loadSkeletonTextures, atlasURI', this.atlasURI, this.atlasPath, this.uid, this.objectName, this.runtime.GetTickCount());
}

loadSkeletonData()
{
console.info('[Spine] loadSkeletonData, atlasURI', this.atlasURI, this.atlasPath, this.objectName, this.sdkType._texturesBatcherInitialized, this.runtime.GetTickCount());
console.info('[Spine] loadSkeletonData, atlasURI', this.atlasURI, this.atlasPath, this.uid, this.objectName, this.sdkType._texturesBatcherInitialized, this.runtime.GetTickCount());

const assetManager = this.sdkType._assetManager;;
const assetTag = this.sdkType._assetTag;
Expand All @@ -189,8 +189,8 @@
// Sentry error reported
if (atlasURI === undefined || atlasURI === null)
{
console.warn('[Spine] loadSkeletonData, atlasURI not set', atlasURI, assetTag, this.atlasURI, assetManager.isLoadingComplete(assetTag), this.atlasPath, this.runtime.GetTickCount());
console.warn('[Spine] objectclass',this.objectName, this.sdkType, this.runtime.GetTickCount());
console.warn('[Spine] loadSkeletonData, atlasURI not set', atlasURI, assetTag, this.uid, this.atlasURI, assetManager.isLoadingComplete(assetTag), this.atlasPath, this.runtime.GetTickCount());
console.warn('[Spine] objectclass',this.objectName, this.sdkType, this.uid, this.runtime.GetTickCount());
if (globalThis.Sentry)
{
globalThis.Sentry.captureException('[Spine] loadSkeletonData, atlasURI not set, object:'+this.objectName);
Expand Down Expand Up @@ -479,10 +479,17 @@
this.initInstance();
}

// First instance to initialize becomes init owner
if(this.sdkType._initOwner == -1)
{
this.sdkType._initOwner = this.uid;
console.info('[Spine] IsSpineReady, initOwner', this.uid, this.objectName, this.runtime.GetTickCount());
}

// Once per object, load texture assets, init spinebatcher
if (!this.sdkType._texturesBatcherInitialized)
{
if(!this.sdkType._texturesBatcherInitializing)
if(!this.sdkType._texturesBatcherInitializing && this.sdkType._initOwner == this.uid)
{
this.sdkType._texturesBatcherInitializing = true;
if (this.runtime.IsPreview() || this.runtime._assetManager._isCordova)
Expand All @@ -500,15 +507,15 @@
const assetTag = this.sdkType._assetTag;

// Once per object, wait for assets to complete loading
if (!assetManager.isLoadingComplete(assetTag))
if (!assetManager.isLoadingComplete(assetTag) && this.sdkType._initOwner == this.uid)
{
return false;
}

// Once per object, load skeletonData, load assets
if (!this.sdkType._skeletonDataInitialized)
{
if(!this.sdkType._skeletonDataInitializing)
if(!this.sdkType._skeletonDataInitializing && this.sdkType._initOwner == this.uid)
{
this.sdkType._skeletonDataInitializing = true;
this.loadSkeletonData();
Expand Down
2 changes: 1 addition & 1 deletion src/c3runtime/spine-draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,6 @@ class SpineBatch {

if (!globalThis.spineBatcher)
{
console.log('[Spine] SpineBatcher init, 1.36.8');
console.log('[Spine] SpineBatcher init, 1.36.9');
globalThis.spineBatcher = new SpineBatch();
}
1 change: 1 addition & 0 deletions src/c3runtime/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
this._tickCount = -1;
this._assetPaths = {};
this._initFailed = false;
this._initOwner = -1;
}

LoadTextures(renderer)
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const C3 = self.C3;

const PLUGIN_ID = "Gritsenko_Spine";
const PLUGIN_VERSION = "1.36.8";
const PLUGIN_VERSION = "1.36.9";
const PLUGIN_CATEGORY = "general";

const PLUGIN_CLASS = SDK.Plugins.Gritsenko_Spine = class SpinePlugin extends SDK.IPluginBase {
Expand Down

0 comments on commit 6d1d6ba

Please sign in to comment.