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
868 stars 195 forks source link

Game broken after update to latest version #1482

Closed paulocoutinhox closed 9 months ago

paulocoutinhox commented 9 months ago

Hi,

My game broken after update to latest version. I only reclone, as suggested.

The line where is happen.

auto background = LayerColor::create(Color4B(64, 31, 7, 255));

Error:

Loading shader: 5 positionTextureColor_vs, positionTextureColor_fs ...
axmol: fullPathForFilename: No file found at positionTextureColor_vs. Possible missing file.
axmol: fullPathForFilename: No file found at positionTextureColor_fs. Possible missing file.
libc++abi: terminating due to uncaught exception of type std::out_of_range: ibstream_view::consume out of range!

Screenshot:

image
rh101 commented 9 months ago

@paulocoutinhox I cannot reproduce the problem. I am assuming you're using Xcode, and building for iOS. Using Xcode 15 on a Mac M1, and a build for iOS, it's running fine on an iPhone 7:

2023-12-08 16:13:27.976534+1100 test1[355:6604] Metal GPU Frame Capture Enabled
2023-12-08 16:13:27.976783+1100 test1[355:6604] Metal API Validation Enabled
...
Loading shader: 5 positionTextureColor_vs, positionTextureColor_fs ...
Loading shader: 7 positionTextureColor_vs, label_normal_fs ...
Loading shader: 0 positionColorLengthTexture_vs, positionColorLengthTexture_fs ...
Loading shader: 1 positionColorTextureAsPointsize_vs, positionColor_fs ...
axmol: QuadCommand: resizing index size from [-1] to [2560]

Just something to note, there are two templates made for these github issues in this repo, one of which is named "Bug report". The reason I'm mentioning it is because it wasn't used in this case, and it can be difficult trying to replicate an issue when information such as the OS, development environment, and target build type is not listed anywhere. The whole point of that template is to act as a reminder to the person filling it out as to what information is required. I strongly suggest you use it for any future reports, otherwise you may forget to include a lot of important information in your post.

Note that given the recent changes to the repo, I deleted the existing local axmol repo, and cloned it again, and re-ran setup.ps1. A fresh project was created, and built via xcode. If you didn't clone it again, or if you didn't delete the existing build folder in your project and recreate it, then perhaps that may be something to try.

aismann commented 9 months ago

Maybe not important but: No problem on Windows

paulocoutinhox commented 9 months ago

It only happen with dev branch.

My steps to reproduce in a new project:

auto visibleSize = _director->getVisibleSize();
auto origin = _director->getVisibleOrigin();
auto safeArea = _director->getSafeAreaRect();
auto safeOrigin = safeArea.origin;

to:

auto visibleSize = _director->getVisibleSize();
auto origin = _director->getVisibleOrigin();
auto safeArea = _director->getSafeAreaRect();
auto safeOrigin = safeArea.origin;

auto background = LayerColor::create(Color4B(64, 31, 7, 255));
addChild(background);

Error:

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib                 0x186800744 __pthread_kill + 8
1   libsystem_pthread.dylib                0x186837c28 pthread_kill + 288
2   libsystem_c.dylib                      0x186745ae8 abort + 180
3   libc++abi.dylib                        0x1867f0b84 abort_message + 132
4   libc++abi.dylib                        0x1867e03b4 demangling_terminate_handler() + 320
5   libobjc.A.dylib                        0x1864b6e68 _objc_terminate() + 160
6   libc++abi.dylib                        0x1867eff48 std::__terminate(void (*)()) + 16
7   libc++abi.dylib                        0x1867f2d34 __cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 36
8   libc++abi.dylib                        0x1867f2ce0 __cxa_throw + 140
9   layerbug                               0x102fd1788 ax::backend::ShaderModuleMTL::ShaderModuleMTL(id<MTLDevice>, ax::backend::ShaderStage, std::__1::basic_string_view<char, ax::backend::ShaderStage::char_traits<char>>) + 1276
10  layerbug                               0x102fcf118 ax::backend::DeviceMTL::newShaderModule(ax::backend::ShaderStage, std::__1::basic_string_view<char, std::__1::char_traits<char>>) + 68
11  layerbug                               0x102fc9f74 ax::backend::ShaderCache::newShaderModule(ax::backend::ShaderStage, std::__1::basic_string_view<char, std::__1::char_traits<char>>) + 288
12  layerbug                               0x102fcf354 ax::backend::ProgramMTL::ProgramMTL(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string_view<char, std::__1::char_traits<char>>) + 80
13  layerbug                               0x102fcf218 ax::backend::DeviceMTL::newProgram(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string_view<char, std::__1::char_traits<char>>) + 68
14  layerbug                               0x102fc3c50 ax::backend::ProgramManager::loadProgram(std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string_view<char, std::__1::char_traits<char>>, unsigned int, unsigned long long, ax::backend::VertexLayoutType) + 500
15  layerbug                               0x102fc9540 ax::backend::ProgramStateRegistry::newProgramState(unsigned int, int) + 296
16  layerbug                               0x102ecad78 ax::Node::setProgramStateWithRegistry(unsigned int, ax::Texture2D*) + 56
17  layerbug                               0x102ee3d18 ax::Sprite::initWithTexture(ax::Texture2D*, ax::Rect const&, bool) + 188
18  layerbug                               0x102ee38b8 ax::Sprite::init() + 32
19  layerbug                               0x102ebdd3c ax::LayerColor::initWithColor(ax::Color4B const&, float, float) + 44
20  layerbug                               0x102ebde54 ax::LayerColor::create(ax::Color4B const&) + 76
21  layerbug                               0x102e562fc HelloWorld::init() + 152
22  layerbug                               0x102e561dc AppDelegate::applicationDidFinishLaunching() + 316
23  layerbug                               0x102faa2d8 ax::Application::run() + 56
24  layerbug                               0x102e56cfc main + 32
25  dyld                                   0x1864dff28 start + 2236
image
rh101 commented 9 months ago

It only happen with dev branch.

The shader changes are only in the dev branch, since v1.0 didn't use the same structure, so I'm not quite sure why you stated that.

  • And run with: axmol run

I don't know if that would cause the issue, since I don't use it, but perhaps someone else may. Can you try building the project from within Xcode to see if it works?

paulocoutinhox commented 9 months ago

Hi,

I tried in my other games and all is broken. If i try create a sprite, it break:

auto background = Sprite::create(backgroundImage);

Error:

Loading shader: 5 positionTextureColor_vs, positionTextureColor_fs ...
axmol: fullPathForFilename: No file found at positionTextureColor_vs. Possible missing file.
axmol: fullPathForFilename: No file found at positionTextureColor_fs. Possible missing file.
libc++abi: terminating due to uncaught exception of type std::out_of_range: ibstream_view::consume out of range!

I only put axmol run to you reproduce, because i tried from xcode too.

rh101 commented 9 months ago

Check the build folder to see if the shaders are actually processed and saved in there, for example, build_arm64/runtime/axslc.

Also check if the shaders have been copied across the output package.

Once again, I cannot reproduce this issue at all.

paulocoutinhox commented 9 months ago

Yes, it is there:

image
ls -l build_arm64/runtime/axslc/positionTextureColor*
-rw-r--r--  1 paulo  staff   901B Dec  8 03:54 build_arm64/runtime/axslc/positionTextureColorAlphaTest_fs
-rw-r--r--  1 paulo  staff   619B Dec  8 03:54 build_arm64/runtime/axslc/positionTextureColor_fs
-rw-r--r--  1 paulo  staff   1.0K Dec  8 03:54 build_arm64/runtime/axslc/positionTextureColor_vs
rh101 commented 9 months ago

Yes, it is there:

What about the generated package, do the files exist in there?

EDIT: Given that you removed links to the source code etc, I'm assuming you found the issue and you got it working?

paulocoutinhox commented 9 months ago

The problem still happen and the final package have only this:

image
rh101 commented 9 months ago

You mentioned that you can reproduce the issue with a new project, so post that project up somewhere if you can (without the build folder).

rh101 commented 9 months ago

@paulocoutinhox I just tested a MacOS arm64 build, and it ran fine. The shaders are all in the correct folder. There is something about your development environment that may be causing all these issues.

halx99 commented 9 months ago

note cmake 3.28.0 required

rh101 commented 9 months ago

note cmake 3.28.0 required

Good point. My MacOS has cmake 3.28 installed, so that could very well be the reason it's working as expected.

paulocoutinhox commented 9 months ago

humm....mine have cmake version 3.27.6

halx99 commented 9 months ago

you should follow DevSetup.md use axmol build -p ios -c

the pwsh build script will auto setup required cmake 3.28.0

paulocoutinhox commented 9 months ago

I follow, but there dont have this info: https://github.com/axmolengine/axmol/blob/dev/docs/DevSetup.md

When i redownload axmol i see it installing cmake 3.28 but it don't change nothing to this problem. I manually install now with brew (brew install cmake).

paulocoutinhox commented 9 months ago

After update to dev branch with the fix https://github.com/axmolengine/axmol/commit/e62d09a718948fc4cddb92dee1c6734383745ba3, it was solved. Thanks.

paulocoutinhox commented 9 months ago

Tested on macOS, iOS, tvOS and Android. Thanks.