axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
922 stars 205 forks source link

[Android] void ax::backend::ProgramGL::compileProgram(): assertion "vertShader != 0 && fragShader != 0" failed' #1373

Closed stephenhurry closed 1 year ago

stephenhurry commented 1 year ago
  1. Build a new Android project on running axmol build -p android -a arm64
  2. Open Android Studio to run it on device
  3. The App is built successfully but crashed at the start, with the following error logcat:
    Abort message: '/.../axmol/core/renderer/backend/opengl/ProgramGL.cpp:190: void ax::backend::ProgramGL::compileProgram(): assertion "vertShader != 0 && fragShader != 0" failed'
    ...
    (ax::backend::ProgramGL::compileProgram()+160)
    /lib/arm64/libninja-axmol.so (ax::backend::ProgramGL::ProgramGL(std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >)+656)
    /lib/arm64/libninja-axmol.so (ax::backend::DeviceGL::newProgram(std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >)+104)
    /lib/arm64/libninja-axmol.so (ax::backend::ProgramManager::loadProgram(std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, unsigned int, unsigned long, ax::backend::VertexLayoutType)+576)
    /lib/arm64/libninja-axmol.so (ax::backend::ProgramManager::getBuiltinProgram(unsigned int)+176)
    /lib/arm64/libninja-axmol.so (ax::backend::Program::getBuiltinProgram(unsigned int)+24)
    /lib/arm64/libninja-axmol.so (ax::backend::ProgramStateRegistry::newProgramState(unsigned int, int)+272)
    /lib/arm64/libninja-axmol.so (ax::Node::setProgramStateWithRegistry(unsigned int, ax::Texture2D*)+84)
    /lib/arm64/libninja-axmol.so (ax::Sprite::setProgramState(unsigned int)+32)
    /lib/arm64/libninja-axmol.so (ax::Sprite::setTexture(ax::Texture2D*)+652
    /lib/arm64/libninja-axmol.so (ax::Sprite::initWithTexture(ax::Texture2D*, ax::Rect const&, bool)+256)
    /lib/arm64/libninja-axmol.so (ax::Sprite::initWithTexture(ax::Texture2D*, ax::Rect const&)+52)
    /lib/arm64/libninja-axmol.so (ax::Sprite::initWithFile(std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, ax::backend::PixelFormat)+220)
    /lib/arm64/libninja-axmol.so (ax::Sprite::create(std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, ax::backend::PixelFormat)+116)
    /lib/arm64/libninja-axmol.so (ax::Sprite::create(std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >)+60)
    /lib/arm64/libninja-axmol.so (ax::MenuItemImage::initWithNormalImage(std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, std::__ndk1::function<void (ax::Ref*)> const&)+112)
    /lib/arm64/libninja-axmol.so (ax::MenuItemImage::create(std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, std::__ndk1::function<void (ax::Ref*)> const&)+160)
    /lib/arm64/libninja-axmol.so (ax::MenuItemImage::create(std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, std::__ndk1::basic_string_view<char, std::__ndk1::char_traits<char> >, std::__ndk1::function<void (ax::Ref*)> const&)+108)
    /lib/arm64/libninja-axmol.so (HelloWorld::init()+256) 
    /lib/arm64/libninja-axmol.so (std::__ndk1::__invoke_return<bool (HelloWorld::*)(), HelloWorld*&>::type std::__ndk1::__mem_fn<bool (HelloWorld::*)()>::operator()<HelloWorld*&>(HelloWorld*&) const+44)
    /lib/arm64/libninja-axmol.so (HelloWorld* ax::utils::createInstance<HelloWorld, bool (HelloWorld::*)()>(bool (HelloWorld::*&&)())+144)
    /lib/arm64/libninja-axmol.so (HelloWorld* ax::utils::createInstance<HelloWorld>()+48)
    /lib/arm64/libninja-axmol.so (AppDelegate::applicationDidFinishLaunching()+652)
    /lib/arm64/libninja-axmol.so (ax::Application::run()+28)
rh101 commented 1 year ago

Can you please check the APK to see if it has the shaders inside it? It'll be the assets\axslc\ path inside the APK.

The APK will be in this path (open the file in WinZip/WinRar or similar): [project folder]\proj.android\app\build\outputs\apk\debug\[filename.apk]

If the files do exist in that path, then put a breakpoint on ProgramManager::loadProgram and find out which shader isn't loading.

EDIT: I can't reproduce the issue on my system using the current source code https://github.com/axmolengine/axmol/commit/bae61737309bb61c9251887da9c9cde93a5fca4e

stephenhurry commented 1 year ago

@rh101 OK I just checked the APK generated and found axslc is missing in the assets folder

rh101 commented 1 year ago

Did you generate a new project with Axmol dev-bae6173? If not, check the changes made to cpp-template-default recently, specifically in the proj.android/app directory.

Ensure you have merged in the Android changes to your project. You can see them here:

templates/cpp-template-default/proj.android/app/build.gradle

stephenhurry commented 1 year ago

I recreated the project and the issue was not reproduced.