Skip to content

Commit

Permalink
1.36.5 remove race condition for AtlasURI
Browse files Browse the repository at this point in the history
  • Loading branch information
MikalDev committed Feb 14, 2021
1 parent 5dc4ca4 commit 0f7c31a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
Binary file added dist/Spine-v1.36.5.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.4",
"version": "1.36.5",
"author": "Mikal and Igor Gritsenko",
"website": "https://gritsenko.github.io/c3_spine_plugin",
"documentation": "https://gritsenko.github.io/c3_spine_plugin",
Expand Down
25 changes: 11 additions & 14 deletions src/c3runtime/instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
this.isPlaying = true;
this.instance = inst;

this.isSkeletonLoaded = false;
this.skeletonInfo = null;
this.renderer = null;
this.gl = null;
Expand All @@ -30,6 +29,7 @@
this.sdkType = this.GetSdkType();

this.atlasPath = "";
this.objectName = this.GetInstance().GetObjectClass().GetName();

if (properties) {
this.jsonPath = properties[0];
Expand All @@ -48,7 +48,6 @@
}

this.isMirrored = false;
this._elementId = "";

this._elementTexture = null

Expand Down Expand Up @@ -83,7 +82,6 @@
initInstance()
{
this.initSpineInProgress = true;
this._elementId = 1; // XXX remove when possible
// Init Spine elements
this.mvp = new spine.webgl.Matrix4();
this.mvp.ortho2d(0, 0, 0, 0); // Texture size unknown at this point
Expand Down Expand Up @@ -166,10 +164,10 @@
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.GetInstance().GetObjectClass().GetName(), this.GetInstance().GetSDKType(), this.runtime.GetTickCount());
console.warn('[Spine] objectclass',this.objectName, this.sdkType, this.runtime.GetTickCount());
if (globalThis.Sentry)
{
globalThis.Sentry.captureException('[Spine] loadSkeletonData, atlasURI not set, object:'+this.GetInstance().GetObjectClass().GetName());
globalThis.Sentry.captureException('[Spine] loadSkeletonData, atlasURI not set, object:'+this.objectName);
}
return;
}
Expand Down Expand Up @@ -205,8 +203,6 @@
const animations = this.skeletonInfo.skeleton.data.animations;
this.animationNames = animations.map(x => x.name);

this.isSkeletonLoaded = true;

this.resize();

spineBatcher.addInstance(this.skeletonInfo, this.skeletonScale, this.GetInstance().GetUID());
Expand Down Expand Up @@ -431,7 +427,7 @@
this.isPlaying = false;
}

IsSpineReady() {
async IsSpineReady() {
// Guard for case where sdkType does not exist (deleted on release)
if (this.sdkType === null || this.sdkType === undefined)
{
Expand All @@ -443,7 +439,7 @@
return false;
}

if (this.isSkeletonLoaded) {
if (this.isLoaded) {
return true;
}

Expand All @@ -459,7 +455,7 @@
if(!this.sdkType._texturesBatcherInitializing)
{
this.sdkType._texturesBatcherInitializing = true;
this.initTexturesBatcher();
await this.initTexturesBatcher();
}
return false;
}
Expand Down Expand Up @@ -503,7 +499,6 @@
this.canvas = null;
this.bgColor = null;
this.isPlaying = null;
this.isSkeletonLoaded = null;
this.skeletonInfo = null;
this.renderer = null;
this.gl = null;
Expand All @@ -519,7 +514,6 @@
this.collisionsEnabled = null;
this.defaultMix = null;
this.isMirrored = null;
this._elementId = null;
this._elementTexture = null
this.pngURI = null;
this.atlasURI = null;
Expand All @@ -545,7 +539,10 @@
}

Tick() {
if (!this.IsSpineReady()) {
// Async function, set this.isLoaded on completion
this.IsSpineReady();

if (!this.isLoaded) {
return;
}

Expand Down Expand Up @@ -627,7 +624,7 @@

var gl = renderer._gl

if (this._elementId == "" || !this.isSkeletonLoaded) return; // elementID not set, can't draw the element
if (!this.isLoaded) return; // Spine instance not loaded, can't draw

var myCanvas = this.canvas;

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 @@ -305,6 +305,6 @@ class SpineBatch {

if (!globalThis.spineBatcher)
{
console.log('[Spine] SpineBatcher init, 1.36.4');
console.log('[Spine] SpineBatcher init, 1.36.5');
globalThis.spineBatcher = new SpineBatch();
}
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.4";
const PLUGIN_VERSION = "1.36.5";
const PLUGIN_CATEGORY = "general";

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

0 comments on commit 0f7c31a

Please sign in to comment.