warrenm / GLTFKit2

A glTF 2.0 asset loader and exporter for Objective-C and Swift.
MIT License
156 stars 27 forks source link

NSInvalidArgumentException -[MDLTextureSampler copyWithZone:] #8

Closed NickRussell95 closed 3 years ago

NickRussell95 commented 3 years ago

I have been using your previous GLTFKit library in an ARKit app on iOS, and it has been working great! I just found this updated version and I'm interested in trying it out.

However, it is unclear if this is designed to work on iOS or only macOS. I noticed this PR: https://github.com/warrenm/GLTFKit2/pull/7 which claims to add iOS support by using UIImage over NSImage. I've pulled that PR locally and am running into another issue when I try to load a GLB file:

2021-08-20 09:46:07.761838+1200 pbr_test[12832:4227191] -[MDLTextureSampler copyWithZone:]: unrecognized selector sent to instance 0x282b36f10
2021-08-20 09:46:07.762520+1200 pbr_test[12832:4227191] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MDLTextureSampler copyWithZone:]: unrecognized selector sent to instance 0x282b36f10'
*** First throw call stack:
(0x1a4adf25c 0x1b8874480 0x1a49ee278 0x1a4ae18b8 0x1a4ae385c 0x101336cb8 0x1013360a0 0x100f76578 0x100f76324 0x100f76640 0x10131f20c 0x10131eb00 0x101383ae8 0x10138532c 0x101387fd0 0x10138743c 0x101396e1c 0x10139773c 0x1ecf81580 0x1ecf8486c)
libc++abi: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MDLTextureSampler copyWithZone:]: unrecognized selector sent to instance 0x282b36f10'
terminating with uncaught exception of type NSException

Details:

warrenm commented 3 years ago

Hey Nick, thanks for the report. This new iteration isn't ready for prime time, but support for iOS and macOS is planned. I'll take a look at this issue and try to resolve it expeditiously. In the meantime, I've pushed a couple of commits that shore up iOS support, including a demo app that shows GLTFKit2-SceneKit interoperability.

warrenm commented 3 years ago

This immediate crash should be resolved with a706dd0. The Model I/O interop is not well-tested, so there may be additional fallout once you take this patch. Feel free to file additional issues as they arise. Thanks again for the report.

NickRussell95 commented 3 years ago

Wow, thanks for such a quick response Warren. I have pulled that and can confirm it is no longer crashing. I will continue my testing and post any other issues I encounter. GLTFKit v1 was already great, so I look forward to seeing where you take this.

PS. Thanks for all your contributions to the Metal community - metalbyexample has been a great learning resource for me.