[Android] Crash when tapping on an EditBox
« on: 09 May 2016, 19:08:20 »
Hey there,

I've just tested tgui on Android and it works well, Buttons and callbacks do what they need to do. But when I create a EditBox there are some problems. Firtly it appears as normal in the App-Display, when I set a Text from code it'll also appear, but as soon as I tap with my finger on the EditBox to type in sth. the App crashes with the standart Android error msg: "Unfortunately, TheApp has stopped."

Here is my Code:

Code: [Select]
auto editBox = std::make_shared<tgui::EditBox>();
editBox ->setSize(700, 100);
editBox ->setPosition(10, 500);
// editBox ->setText("Some Text");
GUI->add(editBox );

At least the virtual keyboard on Android appears, then after like one second it crashes.
I already tryed other keyboards (Googles Keyboard & Samsung Keyboard).
My first try was to compile the 0.7-tgui release. After I got the error I compiled the current code from Github.
Both didn't work.

Have you any solutions fir this problem?

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: [Android] Crash when tapping on an EditBox
« Reply #1 on: 09 May 2016, 19:11:17 »
Are you using the latest SFML version (the master branch from github)? There was a bug in SFML 2.3.2 which caused such a crash, although the crash occured before the keyboard even opened here.
« Last Edit: 09 May 2016, 19:13:55 by texus »

Re: [Android] Crash when tapping on an EditBox
« Reply #2 on: 09 May 2016, 19:19:29 »
Ah, right. The versions.

I use the SFML 2.3.2 release from the SFML website.
My Android Version is 5.0.2 and I have a Samsung Galaxy Alpha.

Now I tried to set the virtual keyboard visible as you described in the bug report and the same behaviour occoured. Keyboard comes alive and then it crashes, unless you set it visible imideatly after the app started. Then it just crashes.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: [Android] Crash when tapping on an EditBox
« Reply #3 on: 09 May 2016, 19:45:49 »
The issue was fixed in SFML on March 1 (while SFML 2.3.2 already dates back from August 2015), so if you compile SFML from github and then rebuild TGUI with that SFML version installed then everything should work.

Re: [Android] Crash when tapping on an EditBox
« Reply #4 on: 09 May 2016, 19:53:56 »
Yeah, just downloaded the latest SFML version, but I get some errors while compiling (during the make command on windows).

Output:

Code: [Select]
[ 53%] Building CXX object src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Texture.cpp.o
In file included from c:/Users/Bruno/Programmieren/Bibliotheken/C++/SFML-2.3.2-github-09-05-16/src/SFML/Graphics/GLCheck.hpp:32:0,

                 from c:/Users/Bruno/Programmieren/Bibliotheken/C++/SFML-2.3.2-github-09-05-16/src/SFML/Graphics/Texture.cpp:30:
c:/Users/Bruno/Programmieren/Bibliotheken/C++/SFML-2.3.2-github-09-05-16/src/SFML/Graphics/Texture.cpp: In member function 'bool s
f::Texture::create(unsigned int, unsigned int)':
c:/Users/Bruno/Programmieren/Bibliotheken/C++/SFML-2.3.2-github-09-05-16/src/SFML/Graphics/GLExtensions.hpp:115:55: error: 'GL_EXT
_sRGB' was not declared in this scope
     #define GLEXT_texture_sRGB                        GL_EXT_sRGB
                                                       ^
c:/Users/Bruno/Programmieren/Bibliotheken/C++/SFML-2.3.2-github-09-05-16/src/SFML/Graphics/Texture.cpp:192:31: note: in expansion
of macro 'GLEXT_texture_sRGB'
     static bool textureSrgb = GLEXT_texture_sRGB;
                               ^
In file included from c:/Users/Bruno/Programmieren/Bibliotheken/C++/SFML-2.3.2-github-09-05-16/src/SFML/Graphics/Texture.cpp:30:0:

c:/Users/Bruno/Programmieren/Bibliotheken/C++/SFML-2.3.2-github-09-05-16/src/SFML/Graphics/GLExtensions.hpp:116:55: error: 'GL_SRG
B8_ALPHA8_EXT' was not declared in this scope
     #define GLEXT_GL_SRGB8_ALPHA8                     GL_SRGB8_ALPHA8_EXT
                                                       ^
c:/Users/Bruno/Programmieren/Bibliotheken/C++/SFML-2.3.2-github-09-05-16/src/SFML/Graphics/GLCheck.hpp:51:28: note: in definition
of macro 'glCheck'
     #define glCheck(expr) (expr)
                            ^
c:/Users/Bruno/Programmieren/Bibliotheken/C++/SFML-2.3.2-github-09-05-16/src/SFML/Graphics/Texture.cpp:215:54: note: in expansion
of macro 'GLEXT_GL_SRGB8_ALPHA8'
     glCheck(glTexImage2D(GL_TEXTURE_2D, 0, (m_sRgb ? GLEXT_GL_SRGB8_ALPHA8 : GL_RGBA), m_actualSize.x, m_actualSize.y, 0, GL_RGBA
, GL_UNSIGNED_BYTE, NULL));
                                                      ^
make[2]: *** [src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/Texture.cpp.o] Error 1
make[1]: *** [src/SFML/Graphics/CMakeFiles/sfml-graphics.dir/all] Error 2
make: *** [all] Error 2

Is it a new bug? And if so, can I somehow get the SFML branch from 1st may?

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: [Android] Crash when tapping on an EditBox
« Reply #5 on: 09 May 2016, 20:00:32 »
That is also an android bug: see here.
You could try to change this in sfml manually: https://github.com/gordonmcshane/SFML/commit/c89d1a987bc8358ea87c56c5aac5f25e4fec8e2d

The commit before they broke sRGB seems to be c4956857faed4b42487f893042116b9745fb9e98 from March 7th, so if you use git to download sfml (using "git clone") then you can do "git checkout c4956857faed4b42487f893042116b9745fb9e98" to get that version.
« Last Edit: 09 May 2016, 20:02:32 by texus »

Re: [Android] Crash when tapping on an EditBox
« Reply #6 on: 09 May 2016, 21:07:47 »
Thank you! It works perfectly now.
And btw what is the difference between an EditBox and a TextBox?

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: [Android] Crash when tapping on an EditBox
« Reply #7 on: 09 May 2016, 22:26:15 »
EditBox is a single line, TextBox is multi-line (including word-wrap and a vertical scrollbar).