Wow, okay so I got the latest version completely working again, and it's got to be one of the weirdest issues I've ever encountered, with an equally weird solution.
So here's a breakdown of the problem, the cause, and the solution, in case this info manages to help anyone else out of the same weird predicament.
Error on previewing game. "Failed to execute 'drawImage' on 'CanvasRenderingContext2D'"
Image files in project folder are glitched, such that hundreds are missing a "Date Modified" value.
Use a program to force all glitched files to have a "Date Modified" value.
I used a freeware program called "Flexible Renamer" to set their "Date Modified" values to match their "Date Last Accessed" values.
After this the game previewed and loaded with no problems. :)
My game project opens in the C2 editor with no apparent problems, but when I try to preview the game, it starts loading, and before any imagery appears, it freezes and pops up the following error message (previewing in NW.js or Chrome or Opera):
So what I gather is that somehow the metadata for about 1000+ files got glitches so that only the "Date Modified" field was missing.
This seemed to be mainly asset files, like images and audio. The xml files were unaffected.
Uncaught InvalidStateError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.
http://localhost:50000/preview.js, line 1900 (col 11)
Alternatively, when previewing in Firefox, I got this less informative version of the same error:
localhost/preview.js, line 1900 (col 0)
"Error loading image" errors logged, essentially one error for every image in the game.
Error loading image 'http://localhost:50000/enturretradius_os-default-000.png':
First attempt to fix it
So, I tried replacing the "loading-logo.png" image with an older copy of my game.
Now when I previewed the game, The logo image appeared, and there was no error popup, but the loading bar under the logo was red, and it only partially filled before freezing.
(Though I suspect that there was probably previously an error for the logo image that was now resolved.)
In Windows Explorer, I went to inspect the actual image files that were failing to load.
The "unloadable" images could be opened and viewed with no issues, but they were bizarrely all missing a "Date Modified" value.
In Windows Explorer, the there was just blank space in the "Date Modified" column for those files.
In the file properties the "Date Modified" entry was just "12:00am" with no day, month, or year.
I'm not sure how or why these files eneded up like this, but I'm wary that it might be a hard drive problem.
Backup your stuff to be safe.
The ugly solution:
First I tried overwriting all my images with copies from an older version of the game, and this did kind of work, as I got far fewer errors in the java console. I'm pretty sure that if I'd replaced them all it would have allowed the game to launch, but it was an ugly solution, because I had changed the names of some of the objects (changing their image names), and I had new objects and images, and some images I'd edited. So overall, I'd have a lot of extra work getting this horrible hybrid of my new and old project back to a fully up-to-date state. I ultimately decided not to go this route, and instead worked out the good solution below.
The good solution:
It turns out it really is just the "Date Modified" value that needs to be fixed for the unloadable files.
I use a freeware program called "Flexible Renamer" to do this, as it can edit files in large batches pretty easily.
These are the steps:
1. Make a backup of your project folder before continuing.
2. In Windows Explorer search the project folder for "*" to get every file and folder in the search results.
3. Sort the search results by "Date Modified" to roughly group all the files with missing dates.
4. In Flexible Renamer, select the "Specify File" tab, and then the "Attributes" sub-tab.
5. In the "Target" section enable "Files", and "Recursive Sub Folders".
6. Set "Timestamp" to "Make the same".
7. Set "Base Date/Time" to "Date Accessed"
8. Set "Apply To" to "Date Modified".
9. Back in Windows Explorer, select all the files that are missing "Date Modified" values, and drag them into Flexible Renamer's file area.
10. In Flexible Renamer, click the "Start Modify" button.
You can redo the file search again, just to make sure you didn't miss any date-less files.
After this all the files in my project folder had "Date Modified" values, and the project previewed and loaded without any problems.