Closed Bug 1671571 Opened 4 years ago Closed 4 years ago

Deprecated loadUrl() API not backwards compatible (null headers)

Categories

(GeckoView :: General, defect)

All
Android
defect

Tracking

(firefox84 fixed)

RESOLVED FIXED
84 Branch
Tracking Status
firefox84 --- fixed

People

(Reporter: sebastian, Assigned: agi)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

This time I tried to just suppress the deprecation warnings to unblock the update, but we started to see a crash in the UI tests:

java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.Map.size()' on a null object reference

     FATAL EXCEPTION: main
Process: org.mozilla.samples.browser, PID: 6199
java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.Map.size()' on a null object reference
	at org.mozilla.geckoview.GeckoSession$Loader.additionalHeaders(GeckoSession.java:1646)
	at org.mozilla.geckoview.GeckoSession.loadUri(GeckoSession.java:1870)
	at mozilla.components.browser.engine.gecko.GeckoEngineSession.loadUrl(GeckoEngineSession.kt:149)
	at mozilla.components.concept.engine.EngineSession.loadUrl$default(EngineSession.kt:546)
	at mozilla.components.browser.session.engine.middleware.LinkingMiddleware$performLoadOnMainThread$1.invokeSuspend(LinkingMiddleware.kt:82)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
	at android.os.Handler.handleCallback(Handler.java:739)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5221)
	at java.lang.reflect.Method.invoke(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:372)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

It looks the previous version had no issues with null headers and now we get a NullPointerException.

I may switch to the new API in AC instead of waiting for a fix in GV - but filed this bug anyways in case we want to fix this in GeckoView too, to be fully backwards compatible.

Switching to the new API was straight-forward. But updating out tests is seems complicated: Bug 1671578

Due to what I mentioned in Bug 1671578, for now I decided to just map null to an empty map on the AC side before passing it to GeckoView.

Well we made a new API so there's no backward compatibility problems involved by definition :)

In general there's no reason to accept a null header (before it was to reduce the numbers of overloads, but with the builder pattern we don't have that problem). And the method is marked as @NonNull so I'm surprised you can even pass null in there in Kotlin.

I'm WONTFIX-ing this, but please reopen if you still think we should support this.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX

Well, it's @Nullable in loadUri() and then you pass it to additionalHeaders():
https://searchfox.org/mozilla-central/rev/e0eb861a187f0bb6d994228f2e0e49b2c9ee455e/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java#1767-1772

The backward compatibility that broke is that existing code using loadUri() just starts to crash now if they have null headers, which didn't happen before.

Ooh I see! Yeah that should be fixed, I'll send a patch soon.

Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---
Assignee: nobody → agi
Pushed by asferro@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/100f7a3b25f8 Don't pass null headers in Loader. r=snorp
Status: REOPENED → RESOLVED
Closed: 4 years ago4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 84 Branch
Has Regression Range: --- → yes
Keywords: regression
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: