Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Android] Issue or not? static sf::Shader creation results in crash.  (Read 3874 times)

0 Members and 1 Guest are viewing this topic.

Daid

  • Newbie
  • *
  • Posts: 29
    • View Profile
Extremely simple. I'm not sure if it is allowed or not. But when I have a global sf::Shader object defined somewhere in the code, the Android version of SFML crashes during startup somewhere in the SFML-Window code (backtrace is sadly useless in this case, so took me quite a while to track down)

Example is simple, just modify the android example code do this:
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>

sf::Shader test_shader;

int main(int argc, char *argv[])
{
    return 0;
}
 

(Tested on a S3 phone, which runs the example fine)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: [Android] Issue or not? static sf::Shader creation results in crash.
« Reply #1 on: July 15, 2015, 10:31:43 am »
You should not use global SFML resources since it can cause many different issues.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: [Android] Issue or not? static sf::Shader creation results in crash.
« Reply #2 on: July 15, 2015, 11:30:27 am »
Despite that, the mobile ports of SFML are still based on OpenGL ES 1.1, which only supports the fixed render pipeline, which means unfortunately there isn't any shader support.

Daid

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: [Android] Issue or not? static sf::Shader creation results in crash.
« Reply #3 on: July 15, 2015, 05:36:05 pm »
Despite that, the mobile ports of SFML are still based on OpenGL ES 1.1, which only supports the fixed render pipeline, which means unfortunately there isn't any shader support.
Which makes the issue even more odd on that end.

You should not use global SFML resources since it can cause many different issues.
Rogger. Wanted to refactor that code anyhow, but it was quick&dirty working quite fine. (But could also explain why OSX is causing issues)

And I think you mean that no SFML objects should be created before main() is run? Cause a private static member isn't strictly global, but constructed at the same point in time and thus will cause the same issues.
« Last Edit: July 15, 2015, 05:40:58 pm by Daid »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: [Android] Issue or not? static sf::Shader creation results in crash.
« Reply #4 on: July 15, 2015, 08:06:29 pm »
Despite that, the mobile ports of SFML are still based on OpenGL ES 1.1, which only supports the fixed render pipeline, which means unfortunately there isn't any shader support.
Which makes the issue even more odd on that end.
How so?
Shaders are not supported. Creating a shader crashes the program. News at 11.
What's odd?

Daid

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: [Android] Issue or not? static sf::Shader creation results in crash.
« Reply #5 on: July 15, 2015, 10:18:35 pm »
What's odd?
Because on windows and linux, when shaders are not supported, creating an sf::Shader object is just fine, but using it results in warning/error notices that shader support is not working.

Not supported, and crash and burn in hell when you try to use it are two very different things. Especially if the shaders have a function to check if they are available and supported.

(I did assume that "not supported" meant "not implemented", at which point crash&burn is really odd for something that isn't even implemented)

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: [Android] Issue or not? static sf::Shader creation results in crash.
« Reply #6 on: July 15, 2015, 10:38:16 pm »
How is it odd that calling something that don't exist crashes? Windows/Linux is different than Android. You can't assume that because something behaves in some way in A, that it will behave the same way in B. Luckily for us, Windows and Linux have fallback that tells you it's not supported. Android does not.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: [Android] Issue or not? static sf::Shader creation results in crash.
« Reply #7 on: July 15, 2015, 11:14:31 pm »
Quote
And I think you mean that no SFML objects should be created before main() is run? Cause a private static member isn't strictly global, but constructed at the same point in time and thus will cause the same issues.
Yes, we mean global scope, not global access. What's important is when the variable is constructed and destroyed, not how it is available to the rest of the code.

Quote
Not supported, and crash and burn in hell when you try to use it are two very different things.
You're absolutely right. A crash is almost always a bug, unless you're doing something that is clearly documented as undefined behaviour.
On platforms that use OpenGL ES 1.1, sf::Shader is an empty shell. So it can be instantiated, and functions can be called. It will just do nothing.
Laurent Gomila - SFML developer