• Runtimes
  • Spine-TS 4.2x runtime problem with readSkeletonData

Hi,

I'm doing a test, trying to migrate code that works with Spine 4.1.x spine files with 4.2.x spine files. Upon trying out the relatively current Spine-ts runtime (4.2.36):

https://unpkg.com/@esotericsoftware/spine-webgl@4.2.36/dist/iife/spine-webgl.js

When trying to load up a skeleton, I'm encountering this problem:

TypeError: First argument to DataView constructor must be an ArrayBuffer
    at new DataView (<anonymous>)
    at new BinaryInput (Matrix4.ts:266:59)
    at SkeletonBinary.readSkeletonData (SkeletonJson.ts:463:27)

If I look at my code, it's around this area:

this.spineObjects['spineAnimationObjects'][spineTarget]['spineAtlas'] = atlas;

let spatlasLoader = new spine.AtlasAttachmentLoader(atlas);
this.spineObjects['spineAnimationObjects'][spineTarget]['spatlasLoader'] = spatlasLoader;

let spskeletonLoader = new spine.SkeletonBinary(spatlasLoader);
this.spineObjects['spineAnimationObjects'][spineTarget]['spskeletonLoader'] = spskeletonLoader;

spskeletonLoader.scale = 1;
let skeletonData = spskeletonLoader.readSkeletonData(this.spineObjects['spineAnimationObjects'][spineTarget]['spineBinaryPath']);

The problem occurs at the last line, in the readSkeletonData function.

The code works with Spine-TS 4.1.x runtime and loading up Spine 4.1 binary outputs. The code gives me problems with Spine-TS 4.2.x runtime and loading up either Spine 4.2.x or 4.1.x binary outputs.

Related Discussions
...

It seems like the issue you're encountering is related to a mismatch between the Spine Editor version used to export the skeleton data and the Spine Runtime version used to load it. This is a common problem when upgrading from one version to another, as the binary format can change between versions.

From the context provided, here are a few steps you can take to resolve the issue:

  1. Ensure Version Compatibility: Make sure that the Spine Editor version used to export the skeleton data matches the Spine Runtime version you are using. For example, if you are using Spine-TS 4.2.36, you should export your skeleton data using Spine Editor 4.2.x.

  2. Re-export Skeleton Data: Re-export your skeleton data using the Spine Editor version that matches your runtime. This ensures that the binary format is compatible with the runtime.

  3. Check for Updates: Ensure that you are using the latest version of the Spine-TS runtime. Sometimes, bugs are fixed in newer versions, so updating might resolve the issue.

  4. Debug the Data: If the problem persists, you can debug the readSkeletonData function to see where it fails. This might give you more insight into what is going wrong.

Here is a snippet of your code with comments to help you debug:

let atlas = this.spineObjects['assetManager'].require(this.spineObjects['spineAnimationObjects'][spineTarget]['spineAtlaspath']);
this.spineObjects['spineAnimationObjects'][spineTarget]['spineAtlas'] = atlas;

let spatlasLoader = new spine.AtlasAttachmentLoader(atlas);
this.spineObjects['spineAnimationObjects'][spineTarget]['spatlasLoader'] = spatlasLoader;

let spskeletonLoader = new spine.SkeletonBinary(spatlasLoader);
this.spineObjects['spineAnimationObjects'][spineTarget]['spskeletonLoader'] = spskeletonLoader;

spskeletonLoader.scale = 1;

// Ensure that 'spineBinaryPath' is a valid ArrayBuffer
let binaryData = this.spineObjects['spineAnimationObjects'][spineTarget]['spineBinaryPath'];
if (!(binaryData instanceof ArrayBuffer)) {
    console.error("spineBinaryPath is not an ArrayBuffer");
}

let skeletonData = spskeletonLoader.readSkeletonData(binaryData);

Make sure that spineBinaryPath is indeed an ArrayBuffer before passing it to readSkeletonData.

If you continue to experience issues, it might be helpful to share the specific skeleton file causing the problem, as this can provide more context for debugging.

Hi Spinebot,

Thanks for the tips, I'll give these a shot later. Right now, the spineBinaryPath in:

this.spineObjects['spineAnimationObjects'][spineTarget]['spineBinaryPath']

is just literally a string path to the skel file. Ex:

"path/to/spineskeletoniwantoload.skel"

I had a require in one working for the 4.1.x spine animations before editing it to just this:

let skeletonData = spskeletonLoader.readSkeletonData(this.spineObjects['assetManager'].require(this.spineObjects['spineAnimationObjects'][spineTarget]['spineBinaryPath']))

Hi Spinebot,

This is the one that I had working with 4.1.x (sorry, the one I put in the OP is something I was trying out):

let skeletonData = spskeletonLoader.readSkeletonData(this.spineObjects['assetManager'].require(this.spineObjects['spineAnimationObjects'][spineTarget]['spineBinaryPath']))

But when using the above readSkeletonData with the 4.2.x runtime, I get this error instead:

Error: String in string table must not be null.
    at SkeletonBinary.readSkeletonData (spine-webgl.js:8676:17)
    at vnManager.spinexloadSkeleton (vnManagerSpinex.js:691:41)
    at vnManager.spinexLoader (vnManagerSpinex.js:391:78)

You can not load .skel files exported from Spine Editor 4.1 in Spine Runtimes 4.2. The editor and runtimes version must match, as the file format may change between versions. Please re-export all your Spine projects using Spine Editor 4.2. See also
https://esotericsoftware.com/spine-versioning

Hi,

Thanks, was able to get it running.