|
|
GameError = GameError or BaseClass()
|
|
|
|
function GameError:__init()
|
|
GameError.Instance = self
|
|
|
|
self.wait_sent_list = {}
|
|
self.last_sent_time = 0
|
|
self.sent_interval = 10
|
|
|
|
self.save_file_error_count = 0
|
|
self.download_file_error_count = 0
|
|
|
|
LogType = UnityEngine.LogType
|
|
|
|
local func = function(msg, stackTrace,msg_type)
|
|
if msg_type == LogType.Warning or msg_type == LogType.Exception or msg_type == LogType.Assert or msg_type == LogType.Error then
|
|
pcall(self.SendErrorToPHP, self, msg, msg_type)
|
|
end
|
|
end
|
|
UnityEngine.Application.logMessageReceived = UnityEngine.Application.logMessageReceived + func
|
|
end
|
|
|
|
function GameError:SendErrorToPHP( str, msg_type )
|
|
if not str or str == "" then return end
|
|
|
|
-- if string.find(str, "NullReferenceException") then
|
|
-- if not self.show_profiler_flag then
|
|
-- self.show_profiler_flag = true
|
|
-- PrintTimerQuest()
|
|
-- LuaProfiler.start()
|
|
-- local function on_delay( )
|
|
-- LuaProfiler.stop()
|
|
-- local str = LuaProfiler._CUSTOM_REPORTS
|
|
-- GameError:SendErrorMsg(str)
|
|
-- print("tanar: [GameError 35]=> str: ",str)
|
|
-- end
|
|
-- setTimeout(on_delay, 1)
|
|
-- end
|
|
-- end
|
|
|
|
local ignore_list =
|
|
{
|
|
[1] = "not wrap to lua",
|
|
[2] = "current connect info",
|
|
[3] = "Stale touch detected",
|
|
[4] = "Animator.GotoState",
|
|
[5] = "create a MonoBehaviour using the 'new' keyword",
|
|
[6] = "Animator does not have an AnimatorController",
|
|
[7] = "Can't call Animator.Update on inactive object",
|
|
[8] = "Invalid Layer Index",
|
|
[9] = "Animator is not playing an AnimatorController",
|
|
[10] = "This MeshCollider requires the mesh to be marked as readable",
|
|
[11] = "auto download res timeout",
|
|
[12] = "res download error occurr",
|
|
[13] = "GLSL: unsupported array parameter",
|
|
[14] = "Mesh does not have normals",
|
|
[15] = "Game object with animator is inactive",
|
|
[16] = "CollisionMeshData couldn't be created",
|
|
[17] = "Mesh does not have normals for Global Illumination",
|
|
[18] = "The request timed out",
|
|
[19] = "Screen position out of view frustum",
|
|
[20] = "Internal: JobTempAlloc has allocations that are more than 4 frames old",
|
|
[21] = "To Debug, enable the define: TLA_DEBUG_STACK_LEAK in ThreadsafeLinearAllocator.cpp",
|
|
}
|
|
|
|
if tonumber(AppConst.EnglineVer) < 89 then
|
|
table.insert(ignore_list,"The AssetBundle 'Memory'")
|
|
end
|
|
|
|
for key,ignore_str in pairs(ignore_list) do
|
|
local find_succeed = string.find(str, ignore_str)
|
|
if find_succeed then
|
|
return
|
|
end
|
|
end
|
|
|
|
local no_show_error_list =
|
|
{
|
|
}
|
|
|
|
if ClientConfig.open_lua_error_win and LuaErrorModel then
|
|
local no_show = false
|
|
for key,no_show_str in pairs(no_show_error_list) do
|
|
local find_succeed = string.find(str, no_show_str)
|
|
if find_succeed then
|
|
no_show = true
|
|
end
|
|
end
|
|
|
|
if not no_show then
|
|
GlobalEventSystem:Fire(LuaErrorModel.SEND_LUAERROR_MESSAGE,str)
|
|
end
|
|
end
|
|
|
|
if not AppConst.UpdateMode or not ClientConfig.php_website_error or ClientConfig.php_website_error == "" then
|
|
return
|
|
end
|
|
|
|
local old_ver_ignore_list =
|
|
{
|
|
[1] = "because another AssetBundle with the same files is already loaded",
|
|
[2] = "You are trying to load data from a www stream which had the following error when downloading",
|
|
}
|
|
|
|
for key,ignore_str in pairs(old_ver_ignore_list) do
|
|
local find_succeed = string.find(str, ignore_str)
|
|
if find_succeed and Scene and Scene.Instance and Scene.Instance:IsSceneProloadFinish() then
|
|
Message.show("网络连接出现异常,请重新进入游戏")
|
|
end
|
|
end
|
|
|
|
if string.find(str,"SQLite") or string.find(str,"database") then
|
|
local date_ver_file = Util.DataPath .. "ver.flag"
|
|
os.remove(date_ver_file)
|
|
Message.show("检测到游戏资源可能损坏,重启游戏后将会自动修复")
|
|
end
|
|
|
|
if string.find(str, "Could not allocate memory: System out of memory!") then
|
|
Message.show("手机运行内存不足,请清理后台应用缓存后,重新进入游戏")
|
|
end
|
|
|
|
if string.find(str, "Disk full") then
|
|
Message.show("储存文件异常,请检查手机剩余空间大小")
|
|
end
|
|
|
|
if string.find(str, "res save error occurr") then
|
|
self.save_file_error_count = self.save_file_error_count + 1
|
|
if self.save_file_error_count > 10 then
|
|
Message.show("储存文件异常,请检查手机剩余空间大小")
|
|
return
|
|
end
|
|
end
|
|
|
|
if string.find(str, "res download error occurr") then
|
|
self.download_file_error_count = self.download_file_error_count + 1
|
|
if self.download_file_error_count > 10 then
|
|
Message.show("游戏资源加载异常,请检查网络连接")
|
|
return
|
|
end
|
|
end
|
|
|
|
local error_str = str
|
|
|
|
local f1 = string.find(error_str,"%[")
|
|
local f2 = string.find(error_str,"%]")
|
|
if f1 == 1 and f2 == 14 then
|
|
error_str = string.sub(error_str,15)
|
|
end
|
|
|
|
local exist = self:ExistSameError(error_str)
|
|
if exist then
|
|
return
|
|
end
|
|
|
|
table.insert(self.wait_sent_list,"<br>")
|
|
table.insert(self.wait_sent_list,error_str)
|
|
|
|
if not self.cur_timer then
|
|
local sent_func = function()
|
|
self:SendNow()
|
|
end
|
|
|
|
local wait_time = self.sent_interval - ( os.time() - self.last_sent_time )
|
|
if wait_time > 0 then
|
|
self.cur_timer = GlobalTimerQuest:AddDelayQuest(sent_func, wait_time)
|
|
else
|
|
sent_func()
|
|
end
|
|
end
|
|
end
|
|
|
|
function GameError:ExistSameError(error_str)
|
|
for _, content in ipairs(self.wait_sent_list) do
|
|
if error_str == content then
|
|
return true
|
|
end
|
|
end
|
|
|
|
return false
|
|
end
|
|
|
|
function GameError:SendNow()
|
|
self.last_sent_time = os.time()
|
|
self.cur_timer = nil
|
|
|
|
if not Util.NetAvailable then
|
|
return
|
|
end
|
|
|
|
local error_str = ""
|
|
for _, content in ipairs(self.wait_sent_list) do
|
|
error_str = error_str .. "\n" .. content
|
|
end
|
|
|
|
self:SendErrorMsg(error_str)
|
|
|
|
self.wait_sent_list = {}
|
|
end
|
|
|
|
function GameError:SendErrorMsg(error_str, force_sent)
|
|
|
|
if not AppConst.UpdateMode and not force_sent then
|
|
return
|
|
end
|
|
|
|
if not Util.NetAvailable then
|
|
return
|
|
end
|
|
|
|
if not error_str or error_str == "" then
|
|
return
|
|
end
|
|
|
|
local role_id = 0
|
|
local role_name = ""
|
|
local role_lv = 0
|
|
if RoleManager and RoleManager.Instance then
|
|
local vo = RoleManager.Instance:GetMainRoleVo()
|
|
if vo then
|
|
role_id = tostring(vo.role_id) or 0
|
|
role_name = vo.name or ""
|
|
role_lv = vo.level or 0
|
|
end
|
|
end
|
|
|
|
local cur_server = 0
|
|
local server_name = "无"
|
|
if LoginController and LoginController.Instance then
|
|
local playerInfo = LoginController.Instance:GetPlatUserInfo()
|
|
if playerInfo then
|
|
cur_server = playerInfo.server_id or 0
|
|
server_name = playerInfo.server_name or ""
|
|
end
|
|
end
|
|
|
|
local no_empty_str = string.gsub(error_str,"%s","")
|
|
if string.len(no_empty_str) < 10 then
|
|
return
|
|
end
|
|
|
|
local no_line_str = string.gsub(error_str, "-", "")
|
|
if string.len(no_line_str) < 10 then
|
|
return
|
|
end
|
|
|
|
-- local scripts_ver = GameConfigUtil.GetValue("scriptsver")
|
|
-- if scripts_ver == "" or not scripts_ver then
|
|
-- scripts_ver = "1.0.0"
|
|
-- end
|
|
local scripts_ver = ClientConfig.scripts_ver or "0"
|
|
scripts_ver = tostring(AppConst.EnglineVer) .. "." .. scripts_ver
|
|
|
|
local ticket = ClientConfig.login_key
|
|
local now_method = "log_client_error"
|
|
local cur_time = tostring(os.time())
|
|
local post_param = {
|
|
time = cur_time,
|
|
content = "version:" .. scripts_ver .. " plat:" .. ClientConfig.plat_name .. " server:" .. server_name .. " lv:" .. role_lv .. " phone:" .. SystemInfo.deviceModel .. "\n" .. error_str,
|
|
method = now_method,
|
|
player_id = role_id,
|
|
nickname = role_name,
|
|
sign = string.lower(Util.md5( ticket .. cur_time .. now_method )),
|
|
server_id = cur_server,
|
|
plat = ClientConfig.plat_name,
|
|
game = "mrzj",
|
|
}
|
|
|
|
local call_func = function(ret,error_msg,data)
|
|
end
|
|
HttpUtil.HttpPostRequest(ClientConfig.php_website_error, post_param, call_func)
|
|
end
|