diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index f8a26944003d..9342116b1f3a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -160,6 +160,7 @@ import org.wordpress.android.widgets.AppRatingDialog; import org.wordpress.android.widgets.WPSnackbar; import org.wordpress.android.widgets.WPViewPager; +import org.wordpress.aztec.exceptions.DynamicLayoutGetBlockIndexOutOfBoundsException; import org.wordpress.aztec.util.AztecLog; import java.io.File; @@ -1620,7 +1621,29 @@ public void initializeEditorFragment() { } ); } + + PostModel currentPost = getPost(); + if (currentPost != null && AppPrefs.isPostWithHWAccelerationOff(currentPost.getLocalSiteId(), + currentPost.getId())) { + // We need to disable HW Acc. on this post + aztecEditorFragment.disableHWAcceleration(); + } aztecEditorFragment.setExternalLogger(new AztecLog.ExternalLogger() { + // This method handles the custom Exception thrown by Aztec to notify the parent app of the error #8828 + // We don't need to log the error, since it was already logged by Aztec, instead we need to write the + // prefs to disable HW acceleration for it. + private boolean isError8828(@NotNull Throwable throwable) { + if (!(throwable instanceof DynamicLayoutGetBlockIndexOutOfBoundsException)) { + return false; + } + PostModel currentPost = getPost(); + if (currentPost == null) { + return false; + } + AppPrefs.addPostWithHWAccelerationOff(currentPost.getLocalSiteId(), currentPost.getId()); + return true; + } + @Override public void log(@NotNull String s) { // For now, we're wrapping up the actual log into an exception to reduce possibility @@ -1631,11 +1654,17 @@ public void log(@NotNull String s) { @Override public void logException(@NotNull Throwable throwable) { + if (isError8828(throwable)) { + return; + } CrashLoggingUtils.logException(new AztecEditorFragment.AztecLoggingException(throwable), T.EDITOR); } @Override public void logException(@NotNull Throwable throwable, String s) { + if (isError8828(throwable)) { + return; + } CrashLoggingUtils.logException( new AztecEditorFragment.AztecLoggingException(throwable), T.EDITOR, s); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostEditorAnalyticsSession.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostEditorAnalyticsSession.java index 80de85f39a1b..21e8e16b9b4d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostEditorAnalyticsSession.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostEditorAnalyticsSession.java @@ -4,9 +4,11 @@ import org.wordpress.android.analytics.AnalyticsTracker.Stat; import org.wordpress.android.fluxc.model.PostModel; import org.wordpress.android.fluxc.model.SiteModel; +import org.wordpress.android.ui.prefs.AppPrefs; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; import org.wordpress.android.util.SiteUtils; +import org.wordpress.android.util.analytics.AnalyticsUtils; import java.io.Serializable; import java.util.ArrayList; @@ -33,6 +35,7 @@ public class PostEditorAnalyticsSession implements Serializable { private Editor mCurrentEditor; private boolean mHasUnsupportedBlocks = false; private Outcome mOutcome = null; + private boolean mHWAccOff = false; enum Editor { GUTENBERG, @@ -77,6 +80,8 @@ enum Outcome { } else { mContentType = "classic"; } + + mHWAccOff = AppPrefs.isPostWithHWAccelerationOff(site.getId(), post.getId()); } public void start(ArrayList unsupportedBlocksList) { @@ -132,6 +137,8 @@ private Map getCommonProperties() { properties.put(KEY_BLOG_TYPE, mBlogType); properties.put(KEY_SESSION_ID, mSessionId); properties.put(KEY_HAS_UNSUPPORTED_BLOCKS, mHasUnsupportedBlocks ? "1" : "0"); + properties.put(AnalyticsUtils.EDITOR_HAS_HW_ACCELERATION_DISABLED_KEY, mHWAccOff ? "1" : "0"); + return properties; } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostUtils.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostUtils.java index a53cbe940224..80fa74116c24 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostUtils.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostUtils.java @@ -20,6 +20,7 @@ import org.wordpress.android.fluxc.model.post.PostStatus; import org.wordpress.android.fluxc.store.PostStore; import org.wordpress.android.ui.posts.RemotePreviewLogicHelper.RemotePreviewType; +import org.wordpress.android.ui.prefs.AppPrefs; import org.wordpress.android.ui.uploads.PostEvents; import org.wordpress.android.ui.uploads.UploadUtils; import org.wordpress.android.ui.utils.UiString.UiStringText; @@ -186,6 +187,8 @@ public static void trackOpenEditorAnalytics(PostModel post, SiteModel site) { if (!post.isLocalDraft()) { properties.put("post_id", post.getRemotePostId()); } + properties.put(AnalyticsUtils.EDITOR_HAS_HW_ACCELERATION_DISABLED_KEY, AppPrefs.isPostWithHWAccelerationOff( + site.getId(), post.getId()) ? "1" : "0"); properties.put(AnalyticsUtils.HAS_GUTENBERG_BLOCKS_KEY, PostUtils.contentContainsGutenbergBlocks(post.getContent())); AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.EDITOR_OPENED, site, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java index 7c0f72338ab6..98a13bf8c178 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppPrefs.java @@ -126,7 +126,10 @@ public enum DeletablePrefKey implements PrefKey { // Widget settings STATS_WIDGET_SELECTED_SITE_ID, STATS_WIDGET_COLOR_MODE, - STATS_WIDGET_DATA_TYPE + STATS_WIDGET_DATA_TYPE, + + // Keep the local_blog_id + local_post_id values that have HW Acc. turned off + AZTEC_EDITOR_DISABLE_HW_ACC_KEYS, } /** @@ -959,4 +962,36 @@ public static void setSystemNotificationsEnabled(boolean enabled) { public static boolean getSystemNotificationsEnabled() { return getBoolean(UndeletablePrefKey.SYSTEM_NOTIFICATIONS_ENABLED, true); } + + private static List getPostWithHWAccelerationOff() { + String idsAsString = getString(DeletablePrefKey.AZTEC_EDITOR_DISABLE_HW_ACC_KEYS, ""); + return Arrays.asList(idsAsString.split(",")); + } + + /* + * adds a local site ID to the top of list of recently chosen sites + */ + public static void addPostWithHWAccelerationOff(int localSiteId, int localPostId) { + if (localSiteId == 0 || localPostId == 0 || isPostWithHWAccelerationOff(localSiteId, localPostId)) { + return; + } + String key = localSiteId + "-" + localPostId; + List currentIds = new ArrayList<>(getPostWithHWAccelerationOff()); + currentIds.add(key); + // store in prefs + String idsAsString = TextUtils.join(",", currentIds); + setString(DeletablePrefKey.AZTEC_EDITOR_DISABLE_HW_ACC_KEYS, idsAsString); + } + + public static boolean isPostWithHWAccelerationOff(int localSiteId, int localPostId) { + if (localSiteId == 0 || localPostId == 0) { + return false; + } + List currentIds = getPostWithHWAccelerationOff(); + String key = localSiteId + "-" + localPostId; + if (currentIds.contains(key)) { + return true; + } + return false; + } } diff --git a/WordPress/src/main/java/org/wordpress/android/util/analytics/AnalyticsUtils.java b/WordPress/src/main/java/org/wordpress/android/util/analytics/AnalyticsUtils.java index e91b790d0629..fea7c9bf8ae3 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/analytics/AnalyticsUtils.java +++ b/WordPress/src/main/java/org/wordpress/android/util/analytics/AnalyticsUtils.java @@ -68,6 +68,7 @@ public class AnalyticsUtils { private static final String NEWS_CARD_VERSION = "version"; public static final String HAS_GUTENBERG_BLOCKS_KEY = "has_gutenberg_blocks"; + public static final String EDITOR_HAS_HW_ACCELERATION_DISABLED_KEY = "editor_has_hw_disabled"; public enum BlockEditorEnabledSource { VIA_SITE_SETTINGS, diff --git a/libs/editor/WordPressEditor/build.gradle b/libs/editor/WordPressEditor/build.gradle index 3767ac8b5566..e49291364c22 100644 --- a/libs/editor/WordPressEditor/build.gradle +++ b/libs/editor/WordPressEditor/build.gradle @@ -5,7 +5,7 @@ buildscript { } ext { - aztecVersion = 'v1.3.33' + aztecVersion = 'v1.3.34' } dependencies { diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java index b28bd1d04c11..516e64bc6b77 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/AztecEditorFragment.java @@ -194,6 +194,8 @@ public AztecLoggingException(Throwable originalException) { private LiveTextWatcher mTextWatcher = new LiveTextWatcher(); + private View mFragmentView; + public static AztecEditorFragment newInstance(String title, String content, boolean isExpanded) { mIsToolbarExpanded = isExpanded; AztecEditorFragment fragment = new AztecEditorFragment(); @@ -219,6 +221,7 @@ public void onCreate(Bundle savedInstanceState) { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_aztec_editor, container, false); + mFragmentView = view; mTitle = view.findViewById(R.id.title); mContent = view.findViewById(R.id.aztec); @@ -2339,4 +2342,8 @@ public void disableContentLogOnCrashes() { public void setExternalLogger(AztecLog.ExternalLogger logger) { mContent.setExternalLogger(logger); } + + public void disableHWAcceleration() { + mFragmentView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); + } } diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index faf94601ba77..80ffe3550c04 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit faf94601ba77958ea62840849f7673ea01643d03 +Subproject commit 80ffe3550c0451ee106607a3d0fbadf1953f2f72