Android Question BCTextEngine error

dragonguy

Active Member
Licensed User
Longtime User
B4X:
java.lang.OutOfMemoryError: Failed to allocate a 37767084 byte allocation with 16777016 free bytes and 18MB until OOM
    at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
    at android.graphics.Bitmap.nativeCreate(Native Method)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:890)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:867)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:787)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Crop(CanvasWrapper.java:587)
    at anywheresoftware.b4a.objects.B4XViewWrapper$B4XBitmapWrapper.Crop(B4XViewWrapper.java:625)

i using BCTextEngine to my app, when debug didn't have any errors, but when i relased to end user, crashlytic receive many bugs.
i still can't figure out what cause this error.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Looks very nice!
Post a screenshot if possible.

I was able to reproduce an out of memory error by changing the screen orientation. Removing the unused background layer seems to fix this issue: https://www.b4x.com/android/forum/t...xt-engine-bbcode-parser-rich-text-view.106207
Update to the latest version, it will reduce the memory required.

Another thing that worth doing is to request more memory by adding this line to the manifest editor:
B4X:
SetApplicationAttribute(android:largeHeap, "true")

If you still get errors with the updated version then post the full error message.
 
Upvote 0

dragonguy

Active Member
Licensed User
Longtime User
Looks very nice!
Post a screenshot if possible.

I was able to reproduce an out of memory error by changing the screen orientation. Removing the unused background layer seems to fix this issue: https://www.b4x.com/android/forum/t...xt-engine-bbcode-parser-rich-text-view.106207
Update to the latest version, it will reduce the memory required.

Another thing that worth doing is to request more memory by adding this line to the manifest editor:
B4X:
SetApplicationAttribute(android:largeHeap, "true")

If you still get errors with the updated version then post the full error message.
Yes, still can't solve my problem (testing device Samsung Note 5)
here is error message from unfilter log
B4X:
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
ViewPostImeInputStage processPointer 0
ViewPostImeInputStage processPointer 1
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
MSG_WINDOW_FOCUS_CHANGED 0
** Activity (main) Pause, UserClosed = false **
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
Bitmap too large to be uploaded into a texture (996x8882, max=8192x8192)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is a different issue. BCTextEngine generates a bitmap with all the text. In this case the generated bitmap is too tall (it will happen on devices with large screens and high DPI). You will need to split it into two BBCodeViews. You can make them as tall as their content and then add them to xCLV one after another.
 
Upvote 0

dragonguy

Active Member
Licensed User
Longtime User
This is a different issue. BCTextEngine generates a bitmap with all the text. In this case the generated bitmap is too tall (it will happen on devices with large screens and high DPI). You will need to split it into two BBCodeViews. You can make them as tall as their content and then add them to xCLV one after another.

how to make the BBCodeViews tall same as my content?
 
Upvote 0

dragonguy

Active Member
Licensed User
Longtime User
Try this:
B4X:
load_text1
BBCodeView1.sv.Height = BBCodeView1.sv.ScrollViewContentHeight + 10dip
BBCodeView1.mBase.Height = BBCodeView1.sv.Height
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private TextEngine As BCTextEngine
    Private BBCodeView1 As BBCodeView
    Private clv1 As CustomListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("1")
    BBCodeView1.Initialize("","")
    TextEngine.Initialize(Activity)
    load_text1
    BBCodeView1.sv.Height = BBCodeView1.sv.ScrollViewContentHeight + 10dip
    BBCodeView1.mBase.Height = BBCodeView1.sv.Height

End Sub

Sub load_text1
clv1.Add(BBCodeView1,"")
End Sub

i get error
B4X:
** Activity (main) Resume **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 127 (BBCodeView)
java.lang.RuntimeException: Object should first be initialized (B4XView).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:69)
    at anywheresoftware.b4a.objects.B4XViewWrapper.getWidth(B4XViewWrapper.java:122)
    at b4a.example.bbcodeview._parseanddraw(bbcodeview.java:173)
    at b4a.example.bbcodeview._settext(bbcodeview.java:117)
    at b4a.example.main._load_text1(main.java:416)
    at b4a.example.main._activity_create(main.java:397)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at b4a.example.main.afterFirstLayout(main.java:104)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:874)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:198)
    at android.app.ActivityThread.main(ActivityThread.java:6729)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
** Activity (main) Resume **
 
Upvote 0

dragonguy

Active Member
Licensed User
Longtime User
Solved the problem when add two BBCodeView!
Look nice!
Thanks!
 

Attachments

  • Screenshot_20190815-210616.png
    Screenshot_20190815-210616.png
    487 KB · Views: 141
Upvote 0
Top