We placed the packaged PlayCanvas files in the iOS installation package for local preview. We encountered a strange issue where the car model would turn black if we switched to another tab during loading and came back later. Sometimes it works fine, but it seems to be a probability issue. If you stay on other pages for a long time before coming back, it will happen 100% of the time. What causes this issue and how can we fix it?
In case you use image based lighting, and generate the prefiltered cubemap in the Editor, the issue could be in the engine. At runtime, this prefiltered cubemap gets converted to envLighting format (new format the engine uses), but when the device is lost, this texture is not regenerated and stays black.
A workaround here is to use envLighting directly … see here how this can be done:
We’ve also encountered this issue, and our solution was to refresh the HDR every 0.2 seconds using reload. However, there’s still a chance of losing the HDR, resulting in the loss of scene lighting. I’m wondering if the loading method in this case can completely solve this problem?
Typically, this only happens when the device context is lost. (when the tab goes inactive, or the app goes to background on the device or sleep).
Instead of reloading every 0.2, you can handle an event that the graphicsDevices fires on itself, called “devicerestored” - that is where the cubemap needs to be re-generated.