microsoft / pxt-arcade

Arcade game editor based on Microsoft MakeCode
https://arcade.makecode.com
MIT License
484 stars 210 forks source link

Unable to host MakeCode Arcade tutorial in GitHub with assets.json file #6220

Closed bmarslandCN closed 1 year ago

bmarslandCN commented 1 year ago

Describe the bug I am trying to create some new tutorials for Code Ninjas and am following the steps and guidance I have followed before when bringing additional assets into a tutorial using the assets.json file in the tutorial, however I cannot seem to get it to work this time! Previously I had this same issue but it was because my assets.json file was corrupted. I have recreated the file 3 separate times and it works in the MakeCode tutorial editor, but not in GitHub. When I remove the assetsjson ... from the tutorial, it works, but as soon as I put it back, it stops loading!

I'm wondering if there's something I'm missing in a different file? Or if there's a limit to how large this file can be? Also, I am doing these tutorials in Python, not blocks (the previous ones I did were in blocks).

To Reproduce Steps to reproduce the behavior:

  1. Go to my repo: https://github.com/Code-Ninjas-Home-Office/arctic-code-quest to check out the code in day1.md (with assets) and day2.md and day3.md (without)
  2. Try loading https://arcade.makecode.com/#tutorial:https://github.com/Code-Ninjas-Home-Office/arctic-code-quest/day1 to see the error
  3. Try loading https://arcade.makecode.com/#tutorial:https://github.com/Code-Ninjas-Home-Office/arctic-code-quest/day2 to see that it works!

Expected behavior I'd like the tutorials to load correctly, with the additional assets I'm adding to them :)

Desktop (please complete the following information):

Thanks!! @kiki-lee @riknoll @abchatra @jwunderl

kiki-lee commented 1 year ago

Hi, Bill! I'm trying to take a look, but it looks like both are working right now and there's not an assetjson in either. Can you point me to a file for one of the tutorials that's giving you a problem?

Here's what I was trying to review: https://raw.githubusercontent.com/Code-Ninjas-Home-Office/arctic-code-quest/master/day1.md

bmarslandCN commented 1 year ago

Hi, Bill! I'm trying to take a look, but it looks like both are working right now and there's not an assetjson in either. Can you point me to a file for one of the tutorials that's giving you a problem?

Here's what I was trying to review: https://raw.githubusercontent.com/Code-Ninjas-Home-Office/arctic-code-quest/master/day1.md

Thanks @kiki-lee! In my frustration I ended up removing the assetsjson just to ensure the tutorial actually worked (because having it in one was blocking the other 2 I had added, too!) but I will add it back now so it can be investigated. Sorry and thank you!!

bmarslandCN commented 1 year ago

@kiki-lee added it back, should be live in a few minutes at https://github.com/Code-Ninjas-Home-Office/arctic-code-quest/blob/master/day1.md

kiki-lee commented 1 year ago

Very odd...it seems to be working for me. Can you take a look at this and let me know if anything is behaving in a way that you don't expect?

https://arcade.makecode.com/#tutorial:67370-48606-36411-02295

bmarslandCN commented 1 year ago

@kiki-lee you clearly have the magic touch, because it also loaded for me! It is the exact same assets.json file I have added, removed, and added back again and again without any luck. I will add it to the other tutorials and see if that causes an issue. Thank you again!

kiki-lee commented 1 year ago

Yep, all me! Actually, it was probably a caching issue. You probably fixed it after the first change, but the web kept pulling the old version in your browser.

Sometimes it helps to either use an incognito window (or sometimes I need to use a whole different web program altogether.)

Happy coding!

bmarslandCN commented 1 year ago

It's happening again unfortunately :( The tutorial works fine when I have it in the MakeCode tutorial editor, but when I transfer it to github and try to load it from there, it does not work. The only thing that seems to be blocking it from running is the assetjson file in the tutorial. This has not been a problem previously, and I cannot figure out what is different in this repo compared to the repo that does work. I'd love any help if possible!!!!

Here's the tutorial link that does not work: https://arcade.makecode.com/#tutorial:https://github.com/Code-Ninjas-Home-Office/arctic-code-quest/day1

Here's the repo it's from: https://github.com/Code-Ninjas-Home-Office/arctic-code-quest/tree/master Here's the tutorial file: https://github.com/Code-Ninjas-Home-Office/arctic-code-quest/blob/master/day1.md Here's a previous repo I've used where it does work (this tutorial was breaking this repo too, which is why I moved it into its own repo): https://github.com/Code-Ninjas-Home-Office/game-building-session-tutorials

Thank you!!! @kiki-lee

kiki-lee commented 1 year ago

Just to be clear, do any of the days work from this repo?

kiki-lee commented 1 year ago

A couple of other questions: 1) Do you know if that's a public repo? 2) Have you done a "release" since fixing the assetjson?

bmarslandCN commented 1 year ago

Just to be clear, do any of the days work from this repo?

None of the days work from the artic-code-quest repo until I remove all the assetjson files. @kiki-lee

bmarslandCN commented 1 year ago

A couple of other questions:

  1. Do you know if that's a public repo?
  2. Have you done a "release" since fixing the assetjson?

The repo is public, but I have not done a release - doing so now!

kiki-lee commented 1 year ago

Do you see this stuff happening in your markdown? Do the files usually work with a """ instead of ` ?

scene.set_background_image(assets.image("""skyBackground"""))

^ This must be a text thing? It doesn't happen in blocks.

bmarslandCN commented 1 year ago

that's how Python formats the asset names in the MakeCode editor, and it didn't seem to be causing an issue. Trying to push a release directly from the MakeCode tutorial now (tried a release from github but it did not work)

kiki-lee commented 1 year ago

Alright, my next guess is that the file is too big. There's a 128K limit, so it might not be getting served. Let me see if image packs take care of the issue.

bmarslandCN commented 1 year ago

Oh I bet it's a big file because there are a lot of image and tile assets in there. And I forgot about image packs - will also look into!

kiki-lee commented 1 year ago

It may not be because it's too big, after all. I do know that extensions can't be bigger than 128k, but when I upload day1 to our test site (which is hosted on Github) it still works: https://arcade.makecode.com/#tutorial:/test/tutorials/day1

I also tried doing an extension version https://arcade.makecode.com/#tutorial:/test/tutorials/day1-a

Would you try uploading this to your repo and see if it works? https://raw.githubusercontent.com/microsoft/pxt-arcade/master/docs/test/tutorials/day1-a.md

bmarslandCN commented 1 year ago

I uploaded it, and it is not working (I did add day1-a to the pxt.json, too) https://arcade.makecode.com/#tutorial:https://github.com/Code-Ninjas-Home-Office/arctic-code-quest/day1-a

I also tried reducing the number of assets in the assetjson file in the original, and it is also not working https://arcade.makecode.com/#tutorial:https://github.com/Code-Ninjas-Home-Office/arctic-code-quest/day1

bmarslandCN commented 1 year ago

@kiki-lee I noticed something this morning that may have contributed to my problems with hosting tutorials. I added a JS tutorial to the repo that has all the blocks tutorials, and it stopped all of the tutorials from opening correctly. As soon as I removed the JS tutorial, the other block ones opened fine. Do I need to always keep block / JS / Python tutorials separate, or is there something I need to update in the pxt.json file (such as on line 28 where the preferred editor is set) to allow for multiple languages? (thanks for your help!!) image

kiki-lee commented 1 year ago

Okay, I think I've figured out what's happening. When I make a repo with both day1 and day1-a, then even day1-a won't open because day1 is too big (and since it's listed in the pxt.json, it has to get loaded, even if you're not using it. )

When I create a repo with only the day1-a file, it loads: https://arcade.makecode.com/#tutorial:https://github.com/kiki-lee/ski-2/day

When I go into the repo with the day1 and day1-a files and remove day1.md from the pxt.json, it loads.

So, theoretically, you should be able to use whatever method you like of getting your files down below 128k (use image packs or delete assets), then remove the files that are too large from your pxt.json.

Let me know how that works!

bmarslandCN commented 1 year ago

Okay, I think I've figured out what's happening. When I make a repo with both day1 and day1-a, then even day1-a won't open because day1 is too big (and since it's listed in the pxt.json, it has to get loaded, even if you're not using it. )

When I create a repo with only the day1-a file, it loads: https://arcade.makecode.com/#tutorial:https://github.com/kiki-lee/ski-2/day

When I go into the repo with the day1 and day1-a files and remove day1.md from the pxt.json, it loads.

So, theoretically, you should be able to use whatever method you like of getting your files down below 128k (use image packs or delete assets), then remove the files that are too large from your pxt.json.

Let me know how that works!

Thank you for helping me figure this out! Guess this means I need to figure out how to use sprite packs now 😆

bmarslandCN commented 1 year ago

@kiki-lee I noticed something this morning that may have contributed to my problems with hosting tutorials. I added a JS tutorial to the repo that has all the blocks tutorials, and it stopped all of the tutorials from opening correctly. As soon as I removed the JS tutorial, the other block ones opened fine. Do I need to always keep block / JS / Python tutorials separate, or is there something I need to update in the pxt.json file (such as on line 28 where the preferred editor is set) to allow for multiple languages? (thanks for your help!!) image

@kiki-lee in case you didn't see this one, is there anything I need to update here with the "preferredEditor" to allow different languages in tutorials in the same repo?

kiki-lee commented 1 year ago

I don't think so, especially since the tutorials are always markdown...but I'm not sure. Maybe the .js file broke it in some other way? Like maybe it was too large? What errors were you getting in the console when you tried to open it?

I may need to tag @riknoll in for this one :)

bmarslandCN commented 1 year ago

@kiki-lee @riknoll no errors actually! Perhaps it was all about the large assetjson file only, and just coincidentally has been tied to large image files that are being used in text-based tutorials! I'm going to continue investigating this today. Thanks!!

bmarslandCN commented 1 year ago

I had created both python-only and JS-only tutorial repos and they both had this in the pxt.json file, which is why I wondered if this would cause a problem hosting tutorials with different languages in the same repo image