ghostty icon indicating copy to clipboard operation
ghostty copied to clipboard

Metal: iOS triggers exception

Open mitchellh opened this issue 6 months ago • 3 comments

Regression since #7620

iOS isn't an important target for us but I like to keep it working so that libghostty remains iOS compatible.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_TtCV11Ghostty_iOS7Ghostty11SurfaceView addSublayer]: unrecognized selector sent to instance 0x103e0b9b0'
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_TtCV11Ghostty_iOS7Ghostty11SurfaceView addSublayer]: unrecognized selector sent to instance 0x103e0b9b0'
*** First throw call stack:
(
	0   CoreFoundation                      0x00000001804c97d4 __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x00000001800937cc objc_exception_throw + 72
	2   CoreFoundation                      0x00000001804defe4 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
	3   UIKitCore                           0x0000000185c858d0 -[UIResponder doesNotRecognizeSelector:] + 232
	4   CoreFoundation                      0x00000001804cda2c ___forwarding___ + 1216
	5   CoreFoundation                      0x00000001804cff6c _CF_forwarding_prep_0 + 92
	6   Ghostty-iOS.debug.dylib             0x0000000108df0258 msg_send.MsgSend(object.Object).msgSend__anon_410122 + 120
	7   Ghostty-iOS.debug.dylib             0x0000000108defdf0 renderer.Metal.init + 692
	8   Ghostty-iOS.debug.dylib             0x0000000108e0279c renderer.generic.Renderer(renderer.Metal).init + 148
	9   Ghostty-iOS.debug.dylib             0x0000000108e0fea0 Surface.init + 1664
	10  Ghostty-iOS.debug.dylib             0x0000000108e11ad8 apprt.embedded.Surface.init + 1328
	11  Ghostty-iOS.debug.dylib             0x0000000108e122b0 apprt.embedded.App.newSurface + 180
	12  Ghostty-iOS.debug.dylib             0x0000000108e12554 apprt.embedded.CAPI.surface_new_ + 68
	13  Ghostty-iOS.debug.dylib             0x0000000108e1264c ghostty_surface_new + 100
	14  Ghostty-iOS.debug.dylib             0x00000001079d50c4 $s11Ghostty_iOS0A0V11SurfaceViewC_10baseConfig4uuidAESv_AC0C13ConfigurationVSg10Foundation4UUIDVSgtcfcSvSgSo24ghostty_surface_config_sazXEfU_ + 52
	15  Ghostty-iOS.debug.dylib             0x00000001079d50f4 $s11Ghostty_iOS0A0V11SurfaceViewC_10baseConfig4uuidAESv_AC0C13ConfigurationVSg10Foundation4UUIDVSgtcfcSvSgSo24ghostty_surface_config_sazXEfU_TA + 24
	16  Ghostty-iOS.debug.dylib             0x00000001079c14d0 $s11Ghostty_iOS0A0V20SurfaceConfigurationV10withCValue4view_xAC0C4ViewC_xSo24ghostty_surface_config_sazKXEtKlFxSPys4Int8VGSgKXEfU_xAOKXEfU_xSayAOGKXEfU_xAPKXEfU_xSrySo0I10_env_var_saGzKXEfU_ + 23	17  Ghostty-iOS.debug.dylib             0x00000001079c78ec $s11Ghostty_iOS0A0V20SurfaceConfigurationV10withCValue4view_xAC0C4ViewC_xSo24ghostty_surface_config_sazKXEtKlFxSPys4Int8VGSgKXEfU_xAOKXEfU_xSayAOGKXEfU_xAPKXEfU_xSrySo0I10_env_var_saGzKXEfU_TA + 	18  Ghostty-iOS.debug.dylib             0x00000001079c1604 $sSa30withUnsafeMutableBufferPointeryqd__qd__SryxGzqd_0_YKXEqd_0_YKs5ErrorRd_0_r0_lF + 232
	19  Ghostty-iOS.debug.dylib             0x00000001079c128c $s11Ghostty_iOS0A0V20SurfaceConfigurationV10withCValue4view_xAC0C4ViewC_xSo24ghostty_surface_config_sazKXEtKlFxSPys4Int8VGSgKXEfU_xAOKXEfU_xSayAOGKXEfU_xAPKXEfU_ + 888
	20  Ghostty-iOS.debug.dylib             0x00000001079c7814 $s11Ghostty_iOS0A0V20SurfaceConfigurationV10withCValue4view_xAC0C4ViewC_xSo24ghostty_surface_config_sazKXEtKlFxSPys4Int8VGSgKXEfU_xAOKXEfU_xSayAOGKXEfU_xAPKXEfU_TA + 52
	21  Ghostty-iOS.debug.dylib             0x00000001079eadd8 $sSa11Ghostty_iOSSSRszlE12withCStringsyqd__qd__SaySPys4Int8VGSgGKXEKlF + 168
	22  Ghostty-iOS.debug.dylib             0x00000001079c0eb0 $s11Ghostty_iOS0A0V20SurfaceConfigurationV10withCValue4view_xAC0C4ViewC_xSo24ghostty_surface_config_sazKXEtKlFxSPys4Int8VGSgKXEfU_xAOKXEfU_xSayAOGKXEfU_ + 324
	23  Ghostty-iOS.debug.dylib             0x00000001079c77d0 $s11Ghostty_iOS0A0V20SurfaceConfigurationV10withCValue4view_xAC0C4ViewC_xSo24ghostty_surface_config_sazKXEtKlFxSPys4Int8VGSgKXEfU_xAOKXEfU_xSayAOGKXEfU_TA + 52
	24  Ghostty-iOS.debug.dylib             0x00000001079eadd8 $sSa11Ghostty_iOSSSRszlE12withCStringsyqd__qd__SaySPys4Int8VGSgGKXEKlF + 168
	25  Ghostty-iOS.debug.dylib             0x00000001079c0ce8 $s11Ghostty_iOS0A0V20SurfaceConfigurationV10withCValue4view_xAC0C4ViewC_xSo24ghostty_surface_config_sazKXEtKlFxSPys4Int8VGSgKXEfU_xAOKXEfU_ + 572
	26  Ghostty-iOS.debug.dylib             0x00000001079c76b4 $s11Ghostty_iOS0A0V20SurfaceConfigurationV10withCValue4view_xAC0C4ViewC_xSo24ghostty_surface_config_sazKXEtKlFxSPys4Int8VGSgKXEfU_xAOKXEfU_TA + 48
	27  Ghostty-iOS.debug.dylib             0x000000010799f184 $sSq11Ghostty_iOSSSRszlE11withCStringyqd__qd__SPys4Int8VGSgKXEKlF + 300
	28  Ghostty-iOS.debug.dylib             0x00000001079c0a48 $s11Ghostty_iOS0A0V20SurfaceConfigurationV10withCValue4view_xAC0C4ViewC_xSo24ghostty_surface_config_sazKXEtKlFxSPys4Int8VGSgKXEfU_ + 208
	29  Ghostty-iOS.debug.dylib             0x00000001079c3c48 $s11Ghostty_iOS0A0V20SurfaceConfigurationV10withCValue4view_xAC0C4ViewC_xSo24ghostty_surface_config_sazKXEtKlFxSPys4Int8VGSgKXEfU_TA + 48
	30  Ghostty-iOS.debug.dylib             0x000000010799f184 $sSq11Ghostty_iOSSSRszlE11withCStringyqd__qd__SPys4Int8VGSgKXEKlF + 300
	31  Ghostty-iOS.debug.dylib             0x00000001079c08d8 $s11Ghostty_iOS0A0V20SurfaceConfigurationV10withCValue4view_xAC0C4ViewC_xSo24ghostty_surface_config_sazKXEtKlF + 552
	32  Ghostty-iOS.debug.dylib             0x00000001079d4d14 $s11Ghostty_iOS0A0V11SurfaceViewC_10baseConfig4uuidAESv_AC0C13ConfigurationVSg10Foundation4UUIDVSgtcfc + 1712
	33  Ghostty-iOS.debug.dylib             0x00000001079d4654 $s11Ghostty_iOS0A0V11SurfaceViewC_10baseConfig4uuidAESv_AC0C13ConfigurationVSg10Foundation4UUIDVSgtcfC + 56
	34  Ghostty-iOS.debug.dylib             0x00000001079b4980 $s11Ghostty_iOS0A0V13SurfaceForAppV_7contentAEy_xGSv_xAC0C4ViewCctcfcAIycfu_ + 168
	35  SwiftUICore                         0x00000001d4be05c4 $s7SwiftUI11StateObjectV3Box33_BDD24532CFCFEBA7264ABA5DE20A4002LLV6update8property5phaseSbACyxGz_AA12_GraphInputsV5PhaseVtFyyScMYcXEfU_TA + 40
	36  SwiftUICore                         0x00000001d4bdfa64 $sScM7SwiftUIE31assumeIsolatedIfLinkedOnOrAfter_7context_4file4linexAA9SemanticsV_SSSgxyKScMYcXEs12StaticStringVSutKs8SendableRzlFZyt_Tt5B5 + 556
	37  SwiftUICore                         0x00000001d4be0140 $s7SwiftUI11StateObjectV3Box33_BDD24532CFCFEBA7264ABA5DE20A4002LLV6update8property5phaseSbACyxGz_AA12_GraphInputsV5PhaseVtF + 224
	38  SwiftUICore                         0x00000001d4857c84 $s7SwiftUI9BoxVTable33_F3A89CF4357225EF49A7DD673FDFEE02LLC6update3elt8property5phaseSbAA34_UnsafeHeterogeneousBuffer_ElementV_SvAA12_GraphInputsV5PhaseVtFZ + 216
	39  SwiftUICore                         0x00000001d485790c $s7SwiftUI22_DynamicPropertyBufferV6update9container5phaseSbSv_AA12_GraphInputsV5PhaseVtF + 128
	40  SwiftUICore                         0x00000001d48caf7c $s7SwiftUI11DynamicBody33_A4C1D658B3717A3062FEFC91A812D6EBLLV11updateValueyyFyyXEfU_ySpy9ContainerQzGXEfU_ + 204
	41  SwiftUICore                         0x00000001d48cca78 $s7SwiftUI11DynamicBody33_A4C1D658B3717A3062FEFC91A812D6EBLLV11updateValueyyFyyXEfU_ySpy9ContainerQzGXEfU_TA + 28
	42  SwiftUICore                         0x00000001d48c9288 $ss17withUnsafePointer2to_q0_x_q0_SPyxGq_YKXEtq_YKs5ErrorR_Ri_zRi_0_r1_lF + 72
	43  SwiftUICore                         0x00000001d48caddc $s7SwiftUI11DynamicBody33_A4C1D658B3717A3062FEFC91A812D6EBLLV11updateValueyyFyyXEfU_ + 256
	44  SwiftUICore                         0x00000001d48caa38 $s7SwiftUI11DynamicBody33_A4C1D658B3717A3062FEFC91A812D6EBLLV11updateValueyyF + 640
	45  SwiftUICore                         0x00000001d4947d58 $s14AttributeGraph0A0VyACyxGqd__c5ValueQyd__RszAA12StatefulRuleRd__lufcADSPyqd__GXEfU_ySv_So11AGAttributeatcyXEfU_ySv_AJtcfu_TA + 28
	46  AttributeGraph                      0x00000001c00ca438 _ZN2AG5Graph11UpdateStack6updateEv + 516
	47  AttributeGraph                      0x00000001c00cac04 _ZN2AG5Graph16update_attributeENS_4data3ptrINS_4NodeEEEj + 428
	48  AttributeGraph                      0x00000001c00d24dc _ZN2AG5Graph20input_value_ref_slowENS_4data3ptrINS_4NodeEEENS_11AttributeIDEjjPK15AGSwiftMetadataRhl + 708
	49  AttributeGraph                      0x00000001c00e8054 AGGraphGetValue + 232
	50  SwiftUICore                         0x00000001d48ca958 $s7SwiftUI11DynamicBody33_A4C1D658B3717A3062FEFC91A812D6EBLLV11updateValueyyF + 416
	51  SwiftUICore                         0x00000001d4947d58 $s14AttributeGra
libc++abi: terminating due to uncaught exception of type NSException

mitchellh avatar Jun 22 '25 14:06 mitchellh

Note: you can test this easily by building and running the Ghostty-iOS target with an iPhone 16 Pro simulator target. It crashes on startup.

mitchellh avatar Jun 22 '25 14:06 mitchellh

I'll be honest, I didn't test iOS at all when writing that code. I think this needs to get the layer and add the sublayer, instead of trying to add a sublayer directly to the view

qwerasd205 avatar Jun 22 '25 14:06 qwerasd205

No problem @qwerasd205. It's not a big deal. Just wanted to make sure we created an issue tracking it so it doesn't bitrot. Its easy enough to test when we have time.

mitchellh avatar Jun 22 '25 14:06 mitchellh

@mitchellh I was searching for iOS terminal apps today and was curious about Ghostty's (been using it mac since v1). With the new iPad OS 26 windows system, it looks way more useful.

Based on this issue, there is no plan to actually implement and support an iOS app in the near future right ?

bilby91 avatar Jun 24 '25 20:06 bilby91

The plan for iOS has been to produce a library that other iOS terminal app developers can embed. IIRC, you can't "just" have a terminal in iOS - you need to bundle a shell and basic commands (could be as simple as busybox, or as complicated as you want). So that really puts it out of scope for the Ghostty project.

We do want to fix any issues that libghostty encounters on iOS though.

jcollie avatar Jun 24 '25 21:06 jcollie