Removing asset that have a tag seems to fail?

This do not work for me! Will get a crash. The asset as a tag on it. In my case it’s a json with tag config. Loaded or unloaded, it does not make a difference.

var assetToRemove = app.assets.get(assetId);
app.assets.remove(assetToRemove);

Thanks

remove: function (tag, item) {
			if (!this._index[tag])
				return;
			if (this._key) {
				if (!this._index[tag].keys[item[this._key]])
					return;
			}
			`var ind = this._index[tag].indexOf(item);` ///crash here
			if (ind === -1)
				return;
			this._index[tag].list.splice(ind, 1);
			if (this._key)
				delete this._index[tag].keys[item[this._key]];
			if (this._index[tag].list.length === 0)
				delete this._index[tag];
		},

Aha, I think I’ve stumbled on this bug a couple of years ago :smiley:

Thought it was fixed if we are talking about that same issue. Is it easy to provide a sample project that reproduces the issue? You can submit an issue about it in the engine repo.

In the meantime, removing that asset prior of removing the asset does it work for you?

asset.tags.remove('tag-name');

Just tried it and trying to remove the tag before seems to crash as well. Will investigate. It crash on tags,remove()

I’ve submitted a bug report here: https://github.com/playcanvas/engine/issues/2451

Nevermind, it was fixed in this PR https://github.com/playcanvas/engine/pull/2432

It should go out with the next engine release early next week.

2 Likes