Closed Filazapovich closed 4 years ago
It is great that we catch the crash and log but I would rather prefer that we find the cause as well. The crash seems to come from the Firebase_Analytics_LogTable function. Could it be that a string is too long?
https://github.com/defold/extension-firebase-analytics/blob/master/firebase/src/firebase.cpp#L161
What do you typically log?
Could it be that you log something other than a string, boolean or number?
In this case I've noticed that size
is still increased:
https://github.com/defold/extension-firebase-analytics/blob/master/firebase/src/firebase.cpp#L179
EDIT: Ah, nvm, if we try to log a value of the wrong type we bail the whole thing. So the question remains, are you logging any large strings?
Nope. This crash is caused by NSInvalidArgumentException
from NSMutableDictionary setObject:forKey:
. I'd try to reproduce it with every lua type. And try to reproduce with nil or NULL values and param name.
Look at firebase C++ src:
https://github.com/firebase/firebase-cpp-sdk/blob/master/analytics/src/analytics_ios.mm#L192 and https://github.com/firebase/firebase-cpp-sdk/blob/master/analytics/src/analytics_ios.mm#L154 . Every invalid parameter value is handled here.
And i'd try NULL name - nothing.
I don't see in source code anything about large strings. size
variable is about count of parameters.
Remember to check v 5.7.0 of the code, not latest master! (although the look the same from a cursory glance)
https://github.com/firebase/firebase-cpp-sdk/blob/v5.7.0/analytics/src/analytics_ios.mm
And you are sure that the key isn't nil? lua_tostring() returns char* or NULL.
We do not check this in the extension and I believe analytics::Parameter also accepts a null value.
https://github.com/defold/extension-firebase-analytics/blob/master/firebase/src/firebase.cpp#L157
Nil key can't exit in lua i think. I'd try to create Parameter with NULL key - handled by https://github.com/firebase/firebase-cpp-sdk/blob/v5.7.0/analytics/src/analytics_ios.mm#L68
Correct a Lua table can't have nil keys, but keys can be of any type and lua_tostring() will return NULL if the type is not string or number:
"The Lua value must be a string or a number; otherwise, the function returns NULL"
But on the other hand it seems like a null name/key is handled in the Firebase code... really weird.
May I suggest that we add some logging in your PR (and not only the lua_error). Could we maybe iterate over the parameters and use dmLogInfo() to print each key-value pair?
Thanks. Let's try this version then and if you are able to gather some data to pinpoint the problem please share it so that we can fix this issue properly!
After throw
NSInvalidArgumentException
fromNSMutableDictionary setObject:forKey:
the app is terminated. This crash is occurred on ~30% of iOS devices but i don't know how to reproduce it.