[SOLVED]
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.
Firstly, thanks dop2000 for your awesome suggestions, especially the JavaScript console error log, as the errors got me looking at the files, which in turn is how I finally noticed that weird missing/blank "Date Modified" meta data, and that was (for some reason) the key to the whole thing.
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.
Short version:
Problem
Error on previewing game. "Failed to execute 'drawImage' on 'CanvasRenderingContext2D'"
Also Javascript console has tons of "Error loading image" errors.
Cause
Image files in project folder are glitched, such that hundreds are missing a "Date Modified" value.
Solution
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. :)
Detailed version:
Problem
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.
Javascript error!
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:
Javascript error!
NS_ERROR_NOT_AVAILABLE:
localhost/preview.js, line 1900 (col 0)
(image: i.imgur.com/q3cnVDg.png)
When I looked at the JavaScript console (I used Firefox) to see what errors had been recorded in the background, I found hundreds of
"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':
(image: i.imgur.com/UPn8vP7.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.
(image: i.imgur.com/qx7eFcq.png)
Checking the JavaScript console, the same procession of "Error loading image" entries were logged.
(Though I suspect that there was probably previously an error for the logo image that was now resolved.)
Cause
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.
Weird.
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.
Solution
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.
Done.
You can redo the file search again, just to make sure you didn't miss any date-less files.
You can also try previewing the project from construct, because the JavaScript console will tell you the names of any files still broken.
After this all the files in my project folder had "Date Modified" values, and the project previewed and loaded without any problems.