AztecEditor-Android
AztecEditor-Android copied to clipboard
Fatal Exception: java.lang.OutOfMemoryError
Failed to allocate a 266338312 byte allocation with 25165824 free bytes and 120MB until OOM, max allowed footprint 166812032, growth limit 268435456 org.wordpress.aztec.AztecParser.withinNestable
java.util.Arrays.copyOf (Arrays.java:3260) java.lang.AbstractStringBuilder.ensureCapacityInternal (AbstractStringBuilder.java:125) java.lang.AbstractStringBuilder.append (AbstractStringBuilder.java:451) java.lang.StringBuilder.append (StringBuilder.java:137) org.wordpress.aztec.AztecParser.withinNestable (AztecParser.kt:439) org.wordpress.aztec.AztecParser.withinHtml (AztecParser.kt:401) org.wordpress.aztec.AztecParser.withinNestable (AztecParser.kt:442) org.wordpress.aztec.AztecParser.withinHtml (AztecParser.kt:401) org.wordpress.aztec.AztecParser.withinNestable (AztecParser.kt:442) org.wordpress.aztec.AztecParser.withinHtml (AztecParser.kt:401) org.wordpress.aztec.AztecParser.withinNestable (AztecParser.kt:442) org.wordpress.aztec.AztecParser.withinHtml (AztecParser.kt:401) org.wordpress.aztec.AztecParser.withinNestable (AztecParser.kt:442) org.wordpress.aztec.AztecParser.withinHtml (AztecParser.kt:401) org.wordpress.aztec.AztecParser.withinNestable (AztecParser.kt:442) org.wordpress.aztec.AztecParser.withinHtml (AztecParser.kt:401) org.wordpress.aztec.AztecParser.withinNestable (AztecParser.kt:442) org.wordpress.aztec.AztecParser.withinHtml (AztecParser.kt:401) org.wordpress.aztec.AztecParser.withinNestable (AztecParser.kt:442) org.wordpress.aztec.AztecParser.withinHtml (AztecParser.kt:401) org.wordpress.aztec.AztecParser.withinHtml (AztecParser.kt:353) org.wordpress.aztec.AztecParser.toHtml (AztecParser.kt:110) org.wordpress.aztec.AztecText.parseHtml (AztecText.kt:1283) org.wordpress.aztec.AztecText.toPlainHtml (AztecText.kt:1254) org.wordpress.aztec.AztecText.toPlainHtml (AztecText.kt:1242) org.wordpress.aztec.AztecText.toPlainHtml$default (AztecText.kt:1241) org.wordpress.aztec.AztecText.paste (AztecText.kt:1574) org.wordpress.aztec.AztecText.onTextContextMenuItem (AztecText.kt:1471) android.widget.Editor$TextActionModeCallback.onActionItemClicked (Editor.java:4181) com.android.internal.policy.DecorView$ActionModeCallback2Wrapper.onActionItemClicked (DecorView.java:2392) com.android.internal.view.FloatingActionMode$3.onMenuItemSelected (FloatingActionMode.java:98) com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected (MenuBuilder.java:776) com.android.internal.view.menu.MenuItemImpl.invoke (MenuItemImpl.java:148) com.android.internal.view.menu.MenuBuilder.performItemAction (MenuBuilder.java:923) com.android.internal.view.menu.MenuBuilder.performItemAction (MenuBuilder.java:913) com.android.internal.view.FloatingActionMode.lambda$setFloatingToolbar$0 (FloatingActionMode.java:123) com.android.internal.view.-$$Lambda$FloatingActionMode$LU5MpPuKYDtwlFAuYhXYfzgLNLE.onMenuItemClick (Unknown Source:2) com.android.internal.widget.FloatingToolbar$FloatingToolbarPopup.lambda$createOverflowPanel$2 (FloatingToolbar.java:1476) com.android.internal.widget.-$$Lambda$FloatingToolbar$FloatingToolbarPopup$E8FwnPCl7gZpcTlX_UaRPIBRnT0.onItemClick (Unknown Source:8) android.widget.AdapterView.performItemClick (AdapterView.java:318) android.widget.AbsListView.performItemClick (AbsListView.java:1192) android.widget.AbsListView$PerformClick.run (AbsListView.java:3169) android.widget.AbsListView.onTouchUp (AbsListView.java:4137) android.widget.AbsListView.onTouchEvent (AbsListView.java:3881) android.view.View.dispatchTouchEvent (View.java:12522) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3024) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2705) com.android.internal.widget.FloatingToolbar$FloatingToolbarPopup$OverflowPanel.dispatchTouchEvent (FloatingToolbar.java:1581) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3030) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2719) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3052) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2719) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3030) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2719) android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:3030) android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2719) android.widget.PopupWindow$PopupDecorView.dispatchTouchEvent (PopupWindow.java:2407) android.view.View.dispatchPointerEvent (View.java:12761) android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:5125) android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:4928) android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4445) android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:4498) android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:4464) android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:4604) android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:4472) android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:4661) android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4445) android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:4498) android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:4464) android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:4472) android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:4445) android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:7120) android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:7089) android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:7050) android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:7223) android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:187) android.os.MessageQueue.nativePollOnce (MessageQueue.java) android.os.MessageQueue.next (MessageQueue.java:326) android.os.Looper.loop (Looper.java:160) android.app.ActivityThread.main (ActivityThread.java:6692) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
Code that error thrown
if (blockHandlers.isNotEmpty()) {
blockHandlers.map { it as IBlockSpanHandler }
.forEach { it.handleSpanStart(out, nestable) }
} else {
out.append("<${nestable.startTag}>") //439th line -> (AztecParser.kt:439)
}
Device Brand: asus Model: ZenFone Max Pro M1 (ZB602KL) (WW) / Max Pro M1 (ZB601KL) (IN) Orientation: Portrait RAM free: 2.21 GB Disk free: 13.08 GB Operating System Version: 9 Orientation: Portrait Rooted: No Crash Date: 18 Apr 2020, 07:15:00 App version: 1.0.8 (9)
Sentry Issue: WORDPRESS-ANDROID-ATF
OutOfMemoryError: Failed to allocate a 246 byte allocation with 16777120 free bytes and 316MB until OOM; failed due to fragmentation (required continguous free 16384 bytes for a new buffer where largest contiguous free 12288 bytes)
at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:163)
at java.lang.StringBuilder.append(StringBuilder.java:311)
at org.json.JSONTokener.nextString(JSONTokener.java:212)
at org.json.JSONTokener.nextValue(JSONTokener.java:107)
...
(21 additional frame(s) were not displayed)
Failed to allocate a 246 byte allocation with 16777120 free bytes and 316MB until OOM; failed due to fragmentation (required continguous free 16384 bytes for a new buffer where largest contiguous free 12288 bytes)
Thank you for the report @ercanduman !
@maxme this looks very similar to https://github.com/wordpress-mobile/WordPress-Android/issues/9997 to me, but I am not sure if they should be combined. Should they be combined? Also, should this be moved to a different repository such as https://github.com/wordpress-mobile/gutenberg-mobile/ ?
@designsimply this is the same class of bug (OOM), but the source of the problem is different from wordpress-mobile/WordPress-Android#9997 - this one should probably moved to https://github.com/wordpress-mobile/AztecEditor-Android
Looking at the stacktrace, this is certainly happening when a huge text is pasted to Aztec (we're doing some string operations and allocating memory after pasting text, at some point memory allocation fails and Aztec crashes).