Add a temporary working way to enable/disable debug at runtime and fix mac/ios occasional crash issue