Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.82k stars 821 forks source link

Output warning to console when enableErrorChecking is set to true? #1014

Closed joshtynjala closed 6 years ago

joshtynjala commented 6 years ago

I just tried a simple Github search, and there are a lot of people setting enableErrorChecking to true:

https://github.com/search?l=ActionScript&q=%22starling.enableErrorChecking+%3D+true%22&type=Code&utf8=%E2%9C%93

In some cases, it's commented out. Sometimes, they might actually be writing shaders. However, I suspect that a lot of beginners might be checking out properties are available on Starling, and the name enableErrorChecking catches their eye. The name makes it sound like a smart thing to enable, so they do it without knowing the consequences. I also suspect that there may be some beginner tutorials out there in the community that set enableErrorChecking to true, and then the issue propagates!

It might be a good idea to add a trace() call in the enableErrorChecking setter to warn developers about it:

public function set enableErrorChecking(value:Boolean):void
{
    _enableErrorChecking = value;
    if (_context) _context.enableErrorChecking = value;
    if (value)
    {
        trace("[Starling] Warning: Setting the enableErrorChecking property to true has a very negative impact on performance, and it prevents ATF textures from being restored on a context loss. Activate enableErrorChecking only when writing custom rendering code (shaders, etc.). Never activate for release builds!");
    }
}
PrimaryFeather commented 6 years ago

That's an excellent point, Josh. I'll add that change first thing tomorrow!