Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken text rendering on macOS #1

Closed
JayFoxRox opened this issue Oct 18, 2020 · 1 comment
Closed

Broken text rendering on macOS #1

JayFoxRox opened this issue Oct 18, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@JayFoxRox
Copy link
Owner

JayFoxRox commented Oct 18, 2020

I experienced an issue with text-rendering on macOS 10.15.7 and the base-game 1.2.3:

Before / After fix:

BrokenFixed


This function creates a buggy OpenGL texture:

https://github.com/cocos2d/cocos2d-x/tree/cocos2d-x-2.2.6 [probably]

Process 1052 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 3.2
    frame #0: 0x000000010015f660 Pro Pinball`cocos2d::CCTexture2D::initWithString(char const*, char const*, float, cocos2d::CCSize const&, cocos2d::CCTextAlignment, cocos2d::CCVerticalTextAlignment)
Pro Pinball`cocos2d::CCTexture2D::initWithString:
->  0x10015f660 <+0>: pushq  %rbp
    0x10015f661 <+1>: movq   %rsp, %rbp
    0x10015f664 <+4>: pushq  %r15
    0x10015f666 <+6>: pushq  %r14
Target 0: (Pro Pinball) stopped.
(lldb) print (char*)$r15
(char *) $68 = 0x0000000100cccd01 "SIGN IN"

Relevant stack:

* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x00007fff39b83186 libGL.dylib`glTexImage2D
    frame #1: 0x000000010015ee18 Pro Pinball`cocos2d::CCTexture2D::initWithData(void const*, cocos2d::CCTexture2DPixelFormat, unsigned int, unsigned int, cocos2d::CCSize const&) + 418
    frame #2: 0x000000010015f581 Pro Pinball`cocos2d::CCTexture2D::initPremultipliedATextureWithImage(cocos2d::CCImage*, unsigned int, unsigned int) + 627
    frame #3: 0x000000010015f2d4 Pro Pinball`cocos2d::CCTexture2D::initWithImage(cocos2d::CCImage*) + 90
    frame #4: 0x000000010015f743 Pro Pinball`cocos2d::CCTexture2D::initWithString(char const*, char const*, float, cocos2d::CCSize const&, cocos2d::CCTextAlignment, cocos2d::CCVerticalTextAlignment) + 227
    frame #5: 0x000000010011df85 Pro Pinball`cocos2d::CCLabelTTF::updateTexture() + 253
  * frame #6: 0x000000010011dbfc Pro Pinball`cocos2d::CCLabelTTF::initWithString(char const*, char const*, float, cocos2d::CCSize const&, cocos2d::CCTextAlignment, cocos2d::CCVerticalTextAlignment) + 248
    frame #7: 0x000000010011dab7 Pro Pinball`cocos2d::CCLabelTTF::create(char const*, char const*, float, cocos2d::CCSize const&, cocos2d::CCTextAlignment, cocos2d::CCVerticalTextAlignment) + 85
    frame #8: 0x00000001000771de Pro Pinball`UI_BUTTON::setLabel(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, float, char const*) + 52
    frame #9: 0x000000010007bbb1 Pro Pinball`UI_SCENE::add_button_with_label(char const*, ANCHOR::TYPE, float, float, float, float, cocos2d::CCObject*, void (cocos2d::CCObject::*)(cocos2d::CCObject*), std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, float) + 61
    frame #10: 0x0000000100083bc2 Pro Pinball`WELCOME_SCENE::init() + 354
    frame #11: 0x000000010008427b Pro Pinball`WELCOME_SCENE::create() + 159

This issue is what inspired this project. I also wasn't the first one to experience this issue.

@JayFoxRox JayFoxRox added the bug Something isn't working label Oct 18, 2020
This was referenced Oct 18, 2020
@JayFoxRox
Copy link
Owner Author

JayFoxRox commented Oct 18, 2020

This is fixed by 89eb20a but some issues remain, such as #2 and some padding/formatting issues.

The patch is implemented as a custom re-implementation of a Cocos2d which appears to be broken on modern macOS.
I didn't even bother investigating why the function is broken and simply re-implemented it from ground-up using Freetype (which comes with its own set of problems). My re-implementation isn't perfect (far from it), but makes the game usable again.

It's worth noting that Ade Barritt (adpag), developer of Pro Pinball, hosts a fork of Cocos2d on his GitHub. It is unclear if this issue is specific to Pro Pinball.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant