Skip to content

Commit

Permalink
Emit onFirstContentfulPaint paint for cached pages
Browse files Browse the repository at this point in the history
The FCP event is not emitted by GeckoView if the page is loaded from the cache
(either HTTP or back/forward). As a result many things are not properly set up
in Wolvic, like the current active session, resulting in many cases in web
contents not visible on app start.

In those cases we should generate and emit it to get things working.
  • Loading branch information
svillar committed Nov 22, 2024
1 parent 892d613 commit ec4a8b7
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import androidx.preference.PreferenceManager;

import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.Surface;
import android.view.inputmethod.CursorAnchorInfo;
Expand Down Expand Up @@ -1364,6 +1367,13 @@ public void onFirstComposite(@NonNull WSession aSession) {
for (WSession.ContentDelegate listener : mContentListeners) {
listener.onFirstContentfulPaint(aSession);
}
} else if (!mState.mIsLoading) {
new Handler(Looper.getMainLooper()).postDelayed(() -> {
// onFirstContentfulPaint is not emitted sometimes when loading a page from
// the cache. This is a workaround to ensure that the event is emitted.
if (!mFirstContentfulPaint)
onFirstContentfulPaint(aSession);
}, 500);
}
}
}
Expand Down

0 comments on commit ec4a8b7

Please sign in to comment.