SessionState.fromString() throws JSONException (typeMismatch)
Categories
(GeckoView :: General, defect, P1)
Tracking
(firefox88 fixed)
| Tracking | Status | |
|---|---|---|
| firefox88 | --- | fixed |
People
(Reporter: sebastian, Assigned: droeh, NeedInfo)
Details
(Whiteboard: [geckoview:m87][geckoview:m88])
Attachments
(1 file)
Related AC Issue: https://github.com/mozilla-mobile/android-components/issues/9332
We recently migrated our session restore code to use JsonReader instead of org.json (to parse from a stream instead of loading everything into memory as string first). With that we stopped catching JSONException since that was only getting thrown by the org.json implemenetation.
However with that we then got crashes and saw that JSONException also gets thrown out of GeckoSession$SessionState.fromString:
org.json.JSONException
at org.json.JSON.typeMismatch(JSON.java:112)
at org.json.JSONObject.<init>(JSONObject.java:168)
at org.json.JSONObject.<init>(JSONObject.java:181)
at org.mozilla.geckoview.GeckoSession$SessionState.fromString(GeckoSession.java:1)
Looking a bit into the code I noticed that sometimes toString() returns null:
https://searchfox.org/mozilla-central/rev/ef900cd2258d4c5d968093f612f807d96e6e7c98/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java#2219-2234
But fromString() doesn't check and always tries to parse as JSONObject:
https://searchfox.org/mozilla-central/rev/ef900cd2258d4c5d968093f612f807d96e6e7c98/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java#2214-2216
fromString()should handlenullvalues.- I guess ideally
fromString()would never throwJSONExceptionsince that is an implementation detail.
| Reporter | ||
Comment 1•5 years ago
|
||
In the meantime we started catching JSONException in AC again to work around the startup crashes that we have been seeing.
| Reporter | ||
Comment 2•5 years ago
|
||
The stacktrace above has the exception message stripped (by Socorro). In a full stacktrace it shows up as:
01-06 13:33:58.883 22743 22743 E ExceptionHandler: org.json.JSONException: Value null of type org.json.JSONObject$1 cannot be converted to JSONObject
01-06 13:33:58.883 22743 22743 E ExceptionHandler: at org.json.JSON.typeMismatch(JSON.java:111)
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
| Assignee | ||
Comment 4•5 years ago
|
||
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Comment 6•5 years ago
|
||
| bugherder | ||
Description
•