[SOLVED] HTML5 not building - possibly a bug?

Hello, I am having a hard time trying to debug the html build of my game. It builds okay as an standard pc build but when I try to build for html5 I get the message:

/game.project
	Unable to find resource assets/objects/bullets/bullet0.go

I narrowed the issue down to my “guns and bullets” implementation using a factory with Dynamic Prototypes and I am providing a minimum example. In the example I have a gun object that starts firing bullet0 objects for 2s then uses factory.set_prototype() to change the projectile to bullet1.

Is very similar to the example show in Dynamic factories but I can’t understand this one doesn’t build HTML5.

html5-not-building.zip (8.2 KB)

Try a clean build?
Maybe ot fails because you didnt put a proxy collections with all your bullets type (go), so the builder doesnt find a static reference to these objects, so it ignores them (like dead code).
Maybe it works for desktop build because you have some cached version of your bullet compiled.

Thank you for your reply Mathias,

Yes, clean builds where the first thing I tried. I even went to the game.project directory and deleted the build and .internal folders.

I am also aware of the need to have the objects static linked so in the example I provided I do have a normal collection with the objects in it. I just tried with loading the collection via a collection proxy but I am still having the same problem.

Ho maybe you missed the c at the end of ‘bullet0.goc’ ?

Well, if I had missed the “c” at the end of bullet0.goc then the standard pc build wouldn’t build correctly, right?

I don’t want to be disrespectful, I know you are busy and is trying to come up with the most common mistakes but if you take the time to open the example you will see what I have. I am actually trying to debug this for a couple of days already and I’ve searched the documentation and the forums for the best of my abilities.

I use a map from hash to string to choose the bullets in game. The minimal example provided is very minimal and should be easy to follow, in my actual game the map is much larger, but the behavior is the same.

Not sure if this is relevant, but I am working on Linux (Debian 13).

It happens even if you only have this line in your project, and nothing else

go.property("bullet", hash("/assets/objects/bullets/bullet0.go"))

and it works if you use add the c like Mathias suggested

go.property("bullet", hash("/assets/objects/bullets/bullet0.goc"))

That it checks the properties differently on HTML and desktop builds is definitely bad, and should be changed or cleared up by the devs, in my opinion.

But on your end, using goc is the correct choice. Or even better, just use a separate factory for each bullet type, as set_prototype is an advanced feature that I would avoid if possible.

1 Like

Thanks @Halfstar,

Well, if do that it builds but then the behavior is wrong. The wrong bullet is loaded at startup like there is only bullet1 linked but not bullet0. With that information I can have a even simpler example that shows the problem.

I do want to use set_prototype if possible because having a factory for each bullet in the real game will be kind of a headache.

Hey folks, I think I nailed it down.

The issue seems to be when I use a property as an hash of a full path of an game object. Like in the example I provided the code below doesn’t build in html5.

go.property("bullet", hash("/assets/objects/bullets/bullet0.go"))

local map = {
	[hash("/assets/objects/bullets/bullet0.go")] = "/assets/objects/bullets/bullet0.goc",
	[hash("/assets/objects/bullets/bullet1.go")] = "/assets/objects/bullets/bullet1.goc"
}

But if instead I use just the hash to of an string that is not a path then everything builds with the correct behaviour. Like in

go.property("bullet", hash("bullet0.go"))

local map = {
	[hash("bullet0.go")] = "/assets/objects/bullets/bullet0.goc",
	[hash("bullet1.go")] = "/assets/objects/bullets/bullet1.goc"
} 

@Mathias I guess this is a bug? Should I open an issue in github?

Thank you all for the support, I think using

go.property("bullet", hash("bullet0.go"))

is acceptable for my case. The insight provided by @Halfstar was pivotal for finding the bug.

Okay so just for completion, here is an minimal minimal (lol) example of how to reproduce the bug. The commented lines below is the implementation that hashes a full path and doesn’t work. The second one only hashes a non-path string and works appropriately.

-- This builds for PC but not for HTML5
--go.property("prototype", hash("/main/prototype.go"))
--local map = {["/main/object.go"] = "/main/prototype.goc"}

-- This builds for PC and HTML5
go.property("prototype", hash("prototype.go"))
local map = {["object.go"] = "/main/prototype.goc"}

html5-build-issue.zip (4.4 KB)

I dug more into it and it turns out it has nothing to do with the factory, you don’t even need one to replicate the problem. It is a go.property() issue. I opened a bug report in github with an even minimal example.

1 Like

Wow that was convoluted!
Good job finding the issue.
Just for the record, I am not this @Mathias_Westerdahl :smiley:
I wish I had his level of expertise, but I am just me :upside_down_face:
See ya

1 Like

@Mathias thank you for the clarification. I actually thought you were Mathias Westerdahl from the dev team :sweat_smile: .

And a I am sorry if I was a bit obnoxious in one of my replies to your suggestions, not a justification but I was a bit on the edge trying to figure out that issue. As you put well, the problem was very convoluted and any suggestion was fair game at that point.

Thanks for trying to help out. :heart:

1 Like