fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
25.1k stars 1.4k forks source link

Text turns into black box in very long Entry #678

Open terminationshock opened 4 years ago

terminationshock commented 4 years ago

Describe the bug:

When inserting a single line of text of more than ~1500 characters into a multi-line entry embedded into a ScrollContainer, a black box is displayed. Observed both on Ubuntu and cross-compiled for Windows.

To Reproduce:

Steps to reproduce the behaviour:

  1. Build the code shown below.
  2. Insert a single line of text of ~1500 characters.
  3. Observe the text turning into a black box.

Screenshots:

Before and after inserting "enough" characters: before after

Example code:

Working version to reproduce:

package main

import (
    "fyne.io/fyne"
    "fyne.io/fyne/app"
    "fyne.io/fyne/layout"
    "fyne.io/fyne/widget"
)

func main() {
    application := app.New()
    win := application.NewWindow("")

    container := fyne.NewContainerWithLayout(layout.NewMaxLayout())
    entry := widget.NewMultiLineEntry()
    container.AddObject(widget.NewScrollContainer(entry))

    win.SetContent(container)
    win.Resize(fyne.NewSize(400, 400))
    win.ShowAndRun()
}

Device (please complete the following information):

andydotxyz commented 4 years ago

Yes it seems like the text render bails if it's wider than 16430px wide :(

zdima commented 3 years ago

seems related to fine 1.*. can't reproduce with 2.0.3 and line of 1600 characters:

package main

import (
    "fyne.io/fyne/v2"
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/container"
    "fyne.io/fyne/v2/layout"
    "fyne.io/fyne/v2/widget"
)

func main() {
    application := app.New()
    win := application.NewWindow("")

    c := fyne.NewContainerWithLayout(layout.NewMaxLayout())
    entry := widget.NewMultiLineEntry()
    c.AddObject(container.NewHScroll(entry))

    win.SetContent(c)
    win.Resize(fyne.NewSize(400, 400))
    win.ShowAndRun()
}
andydotxyz commented 3 years ago

It would be nice if it has gone away, but on develop I have seen it happen in some very rare (long, long lines) cases. Of course with RichText work we are able to split long lines into multiple text segments so we could work around it if the issue is still there.

changkun commented 3 years ago

I tested this on Ubuntu 20.04 with latest develop (831aa152fe9ace29d975870be48a6a395a8927cf), the issue remains to exist. Here is a text to copy-pasting for reproducing the issue:

ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

Code as same as https://github.com/fyne-io/fyne/issues/678#issuecomment-864481313 image

andydotxyz commented 3 years ago

This should go away with the new text render code that is being introduced in 2.2, but we should keep this open to remember

BabySid commented 2 years ago

I have the same problem. Looking forward to the version 2.2.

sh1luo commented 1 year ago

I have the same problem too within version 2.2.4.

andydotxyz commented 1 year ago

The new text render code did not make it in to 2.2 - that's why the issue is still open. It is however being actively developed now and the first of the PRs is open ready for the next big release.

winfordguo commented 1 year ago

I have the same problem too within version 2.3.1. If I set it's Wrapping = fyne.TextWrapBreak or fyne.TextWrapWord, it will be "ANR"

andydotxyz commented 1 year ago

Yup, this is still open. The new code is all in place but we have still to work on the final piece which is using a glyph texture atlas instead of the current line caching. It will be in 2.4.0, if not before.

steampoweredtaco commented 4 days ago

I have a use case that ends up with long lines as well. Might as well throw up the test code I initially wrote that makes this easy to demonstrate with various widgets with text.

package main

import (
    "fmt"
    "fyne.io/fyne/v2"
    "fyne.io/fyne/v2/app"
    "fyne.io/fyne/v2/container"
    "fyne.io/fyne/v2/widget"
    "strings"
    "time"
)

const (
    startValue = 3600
    jumpValue  = 1
    times      = 100

    // these are the values to see when button breaks
    // startValue = 3350
    // jumpValue  = 1
    // times      = 100
)

var newWidget = widget.NewLabel

// var newWidget = widget.NewRichTextWithText
// var newWidget = func(text string) fyne.CanvasObject {
//  return widget.NewButton(text, func() {})
// }

func main() {
    a := app.New()
    w := a.NewWindow("VBox/Label test")
    w.Resize(fyne.NewSize(800, 600))

    vBox := container.NewVBox()
    var b strings.Builder
    for i := 0; i < startValue; i++ {
        b.WriteByte('A')
    }

    vBox.Add(newWidget(fmt.Sprintf("%d-%s", startValue, b.String())))
    scroll := container.NewScroll(vBox)
    w.SetContent(scroll)
    go func() {
        b.WriteByte('A')
        for cnt := 0; cnt < times; cnt++ {
            time.Sleep(10 * time.Millisecond)
            for i := 0; i < jumpValue; i++ {
                b.WriteByte('A')
            }
            text := b.String()
            vBox.Add(newWidget(fmt.Sprintf("%d-%s", len(text), text)))
            scroll.Refresh()
        }
    }()
    w.ShowAndRun()
}

image

image