I had a theory about where the missing tiles might be, because I couldn't find any direct errors in the source code for loading the tiles. My theory was that the tiles are not actually missing, but are drawn behind all the layers. To test that theory, I wrote the same application in C, where I added code that turns off the background layer when the first action button is pressed.
When I turned off the background layer, the tiles that were missing became visible. So now we know that the tiles are not actually missing, they are just drawn behind all the other layers. Maybe it's because of the priority of the layers, but I'm not sure. What do you think?