Android Question BCTextEngine error

Discussion in 'Android Questions' started by dragonguy, Aug 13, 2019 at 1:33 PM.

  1. dragonguy

    dragonguy Active Member Licensed User

    Code:
    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.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. dragonguy

    dragonguy Active Member Licensed User

    I already sent to email.

    Thank you.
     
  4. Erel

    Erel Administrator Staff Member Licensed 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:
    Code:
    SetApplicationAttribute(android:largeHeap, "true")
    If you still get errors with the updated version then post the full error message.
     
  5. dragonguy

    dragonguy Active Member Licensed User

    Yes, still can't solve my problem (testing device Samsung Note 5)
    here is error message from unfilter log
    Code:
    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)
     
  6. Erel

    Erel Administrator Staff Member Licensed 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.
     
  7. dragonguy

    dragonguy Active Member Licensed User

    how to make the BBCodeViews tall same as my content?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Try this:
    Code:
    load_text1
    BBCodeView1.sv.Height = BBCodeView1.sv.ScrollViewContentHeight + 
    10dip
    BBCodeView1.mBase.Height = BBCodeView1.sv.Height
     
  9. dragonguy

    dragonguy Active Member Licensed User

    Code:
    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
    Code:
    ** 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 **
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    You should never initialize BBCodeView yourself. It should be added with the designer.
     
  11. dragonguy

    dragonguy Active Member Licensed User

    Solved the problem when add two BBCodeView!
    Look nice!
    Thanks!
     

    Attached Files:

    Erel likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice