Cocos2d-x v4.0 crash on iphone which don't support metal

Cocos2d-x v4.0 crash on iphone which don't support metal
0

Hello

I am working to upgrade my project to v4.0, I create a simple hello world project and run it on ios simulator. It’s working well in which simulator support metal (i.e, iphone 6s-ios13.2.2) but it’s crashing in which simulator doesn’t support metal (i.e iphone 5s-ios12.2).

Is it a bug in cocos2d-x v4.0 or I am missing something?

Thanks

We can ask @zhangxm to take a look at this. Can you provide crash logs, please?

The v4 only support metal, no OpenGL ES on iOS.

— update —

iOS
iOS
iOS
iOS

I can’t log the stack trace for this crash that’s why I attached a screenshot.

What I understand:
in

[device.name UTF8String];

device.name is null, that’s why when it tries to convert to UTF8String it’s crashing. When I set a default value to _deviceName like

_deviceName = “Simulator”;

Then it’s crashing in different place related to Metal.

N.B: My environment is Xcode 11.2.1, ios 12.2 simulator iphone 5s, MacOS Catalina version 10.15.1, cocos2d-x v4.0

Thank you.

@yinjimmy
But I was read an article about v4 where someone told Metal will work alongside OpenGL, If device does not support Metal then engine automatically switch to OpenGL rendering.

I was waiting for that a long time.

Finally bad luck to me. :smirk: :roll_eyes:

Thank you

no OpenGL ES here :wink:

How it’s possible no OpenGL? how it works on Android then?

If Cocos2d-x v4 is deciding at compile time whether to include OpenGL or Metal, then that is, IMHO, a serious oversight.

It’s not like developers can have multiple versions of their app on the AppStore, one for metal and another for OpenGL, since that, at the very least, would be confusing to users, who wouldn’t have the slightest idea which to choose. This would also cause issues with app rankings on the store, and I can imagine a lot of other problems associated with that too. Also, if I recall correctly, Apple had issues with allowing the same app on the store under a different name, but this may no longer be the case.

The decision of the game engine using Metal or OpenGL should have been done at run-time, and if that isn’t possible, then the Cocos2d-x team should consider adding support for this. The check should be based on the iOS version, since that seems to be the safest to use.

sorry for confuse. on iOS, only have Metal.

I check the source. Maybe I’m wrong.

cmake

if(ANDROID OR WINDOWS OR LINUX) 

list(APPEND COCOS_RENDERER_HEADER
    renderer/backend/opengl/BufferGL.h
...
)

list(APPEND COCOS_RENDERER_SRC
    renderer/backend/opengl/BufferGL.cpp
...
)

else() # mac / ios

list(APPEND COCOS_RENDERER_HEADER
    renderer/backend/metal/BufferMTL.h
...

list(APPEND COCOS_RENDERER_SRC
    renderer/backend/metal/BufferMTL.mm
...
)

endif()

We can ask @zhangxm to clarify to ensure, but:

if you are on iOS/Mac, your game is rendered by Metal and therefore the device it is running on has to support metal. This means something like an iPhone 5 and above.

If you are on something else, OpenGL. This was a mostly drop in upgrade, minus a few things that were OpenGL specific and these are covered in the Upgrade Guide.

I cannot find the actual source I am referring to, but few months ago I remember reading about how supported is metal on most devices that currently users use.

Long story short, less than 2% of the devices do not support metal or have an OS version that does not support it. I assume this will be less than 0.5% within a year.

So, the bottom line is, using metal only does not rule a lot of users out.

1 Like

Thanks. I know the team researched a lot before making these important decisions.

We are looking at a 5% iPad userbase that doesn’t have metal support. That’s not an irrelevant amount at scale…

5% is how many users though that have

iPad mini 2
iPad Air

So 5% of your users have a 6 year old devices is what you are saying?

cocos2dx supports iOS 8+ according to the documentation, with this the following devices are dropped due to the switch to metal-only: (these all support iOS 9+)

  • iPad 2
  • iPad 3
  • iPad Mini
  • iPad 4

Yes, the above devices make 5% of our userbase.

(source https://developer.apple.com/library/archive/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/DeviceCompatibilityMatrix/DeviceCompatibilityMatrix.html)

One more question: how many revenue in % generate that 5% of users?

Percentage of devices are very different from app to app. I assume Guykun refers to his rhythm game so iPads usually have larger user base (since such genre is better played on a larger display).

But, at least in my opinion, anything that has less than 10% can be taken into account as “calculated loss”, as long as it does not provide a significant revenue % on its own (which is rarely the case).

Putting all this aside, I guess that those who want 100% coverage should stick to 3.x branch until Apple decides it is mandatory to use metal. I have not checked how easy would it be to implement runtime render switch so there is still a chance that we might see that in 4.1 or such.

1 Like

Sure, it does vary per app and there’s no official statistics on this. We also won’t be disclosing revenue distributions.

But, at least in my opinion, anything that has less than 10% can be taken into account as “calculated loss”,

10% is however definitely not an acceptable loss in device support, especially when there is no notable gain to be made in performance or in revenue (performance gains for a well-running apps would be negligible)
For applications with large userbases I’ve seen 1% treated as unacceptable. Just like crash rates you wouldn’t accept a 90% crash-free metric, accepting 90% device support just for the sake of ‘possible future-proofing’ is unacceptable.

At this time unless OpenGL is added as a fallback or Apple removes OpenGL support fully, it seems unadvisable for anyone with a production application to update to v4.

It is a business decision in the end. To me, if that 10% of devices bring less than 5% of total revenue, and if that means I do not have to support and debug 2 different render backends, I would take that loss as I can compensate it with more free time to do something else.

If I were to start a fresh mid-size game now, I would go with 4.x as metal will be vastly supported or even mandatory by the time the game hits release. For current games built on OpenGL, yes there is no significant gain currently unless you want to future-proof yourself sooner than later.

EDIT: just to make myself clear here, I am talking about percentage, but 10% of 10000$ and 10% of 1000000$ is obviously something that should be taken into account differently.

Yep, v4 only supports metal on iOS/macOS. If you want to use OpenGL/OpenGL ES, then you can still use v3.

1 Like