Skip to content

feat(#15): allow disabling WebView hardware acceleration to stop smiley flicker#244

Draft
jim-daf wants to merge 1 commit into
ForumHFR:masterfrom
jim-daf:fix/issue-15-toggle-webview-hardware-acceleration
Draft

feat(#15): allow disabling WebView hardware acceleration to stop smiley flicker#244
jim-daf wants to merge 1 commit into
ForumHFR:masterfrom
jim-daf:fix/issue-15-toggle-webview-hardware-acceleration

Conversation

@jim-daf

@jim-daf jim-daf commented Apr 26, 2026

Copy link
Copy Markdown

Closes #15.

Issue recap

On certain devices the WebView used to display topic posts flickers entire text blocks whenever an animated smiley is on screen, as shown in the linked YouTube clip. The reporter suspected hardware-accelerated rendering and asked for a user preference to disable it.

Fix

Teach NestedScrollingWebView about a single boolean preference, pref_disable_webview_hardware_accel. When the flag is on, the WebView is created with LAYER_TYPE_SOFTWARE, which is the standard Android workaround for hardware-rendering glitches inside a WebView. Two small public helpers (setSoftwareLayerType and setHardwareLayerType) are exposed so callers can flip the rendering mode at runtime if the preference is changed without rebuilding the fragment.

public static final String PREF_DISABLE_HARDWARE_ACCELERATION =
        "pref_disable_webview_hardware_accel";

public NestedScrollingWebView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
    applyHardwareAccelerationPreference(context);
}

public void setSoftwareLayerType() {
    setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

private void applyHardwareAccelerationPreference(Context context) {
    final SharedPreferences prefs =
            PreferenceManager.getDefaultSharedPreferences(context);
    final boolean disableHwAcceleration =
            prefs.getBoolean(PREF_DISABLE_HARDWARE_ACCELERATION, false);
    if (disableHwAcceleration) {
        setSoftwareLayerType();
    }
}

Why this is safe by default

  • The new preference defaults to false, so unaffected users keep the existing hardware-accelerated rendering path.
  • All changes live inside NestedScrollingWebView, so no other Activity, Fragment or layout file needs to be touched in this PR.
  • A follow-up PR can wire a checkbox into SettingsActivity so the option is discoverable in the UI. Until then, advanced users can flip the SharedPreferences key manually and immediately benefit from the workaround.

Validation

  • Manual: setting the preference to true and reopening a topic with animated smileys eliminates the flicker on a Samsung Galaxy S6 reproducer.
  • Manual: leaving the preference unset behaves exactly like master, confirmed by visually diffing the smiley animation against an unmodified build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bloc de texte clignotant lorsque smiley animé

1 participant