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

x/mobile: iOS framework, app crashes on launch for 1.18 #51784

Closed
kstanmartin opened this issue Mar 18, 2022 · 15 comments
Closed

x/mobile: iOS framework, app crashes on launch for 1.18 #51784

kstanmartin opened this issue Mar 18, 2022 · 15 comments
Labels
mobile Android, iOS, and x/mobile
Milestone

Comments

@kstanmartin
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.18 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

$ go env 
GOOS="darwin"
GOARCH="amd64"
...

What did you do?

  1. Upgraded to version 1.18.
  2. Build iOS framework for iOS app.
$ gomobile bind -target=ios -o Frameworks/helper.framework
  1. iOS framework is built with no issues.
  2. Attach framework and start Flutter iOS example app:
$ cd example
$ flutter run

What did you expect to see?

App running happily.

What did you see instead?

App tried to launch, white background becomes visible, but closes abruptly.
Here's the console log:

Running pod install...                                           1,031ms
Running Xcode build...                                                  
 └─Compiling, linking and signing...                         5.8s
Xcode build done.                                           26.1s
(lldb) signal 16 received on thread with no signal stack
fatal error: non-Go code disabled sigaltstack


runtime stack:
runtime: unexpected return pc for runtime.sigtramp called from 0x1df14ad48
stack: frame={sp:0x130040810, fp:0x1300408e0} stack=[0x1300386f0,0x130040af0)
0x0000000130040710:  0x0000000130040768  0x0000000000000000 
0x0000000130040720:  0x0000000000000000  0x0000000000000000 
0x0000000130040730:  0x0000000000000000  0x0000000000000000 
0x0000000130040740:  0x0000000000000000  0x0000000000000000 
0x0000000130040750:  0x0000000000000004  0x00000001300407d8 
0x0000000130040760:  0x0000000100dde16c   0x0000000100000010 
0x0000000130040770:  0x00000001010f85c0  0x0000000130040798 
0x0000000130040780:  0x0000000000000000  0x0000000000000000 
0x0000000130040790:  0x0000000000000000  0x0000000000000000 
0x00000001300407a0:  0x0000000000000000  0x0000000000000000 
0x00000001300407b0:  0x0000000000000000  0x0000000000000000 
0x00000001300407c0:  0x00000001300021a0  0x0000000130040910 
0x00000001300407d0:  0x0000000130040978  0x0000000130040808 
0x00000001300407e0:  0x0000000100ddd7c4   0x0000000000000010 
0x00000001300407f0:  0x0000000130040910  0x0000000130040978 
0x0000000130040800:  0x0000000000000000  0x0000000130040900 
0x0000000130040810: <0x00000001df14ad48  0x0000000000000010 
0x0000000130040820:  0x0000000130040910  0x0000000130040978 
0x0000000130040830:  0x855ee83f1200706a  0x0000000130040978 
0x0000000130040840:  0x00000001f685d000  0x00000001011292f4 
0x0000000130040850:  0x0000000000000000  0x0000000000000000 
0x0000000130040860:  0x0000000000000000  0x00000001010dff80 
0x0000000130040870:  0x0000000100f8b670  0x00000001300021a0 
0x0000000130040880:  0x0000000130040808  0x0000000000000000 
0x0000000130040890:  0x0000000000000000  0x0000000000000000 
0x00000001300408a0:  0x0000000000000000  0x0000000000000000 
0x00000001300408b0:  0x0000000000000000  0x0000000000000000 
0x00000001300408c0:  0x0000000000000000  0x0000000000000000 
0x00000001300408d0:  0x0000000000000000  0x0000000000000000 
0x00000001300408e0: >0x00000001011292f4  0x0000000000000003 
0x00000001300408f0:  0x000000000000007d  0x0000000130040f58 
0x0000000130040900:  0x0000000130040d58  0x0000000100daf4fc  
0x0000000130040910:  0x0000000000000010  0x0000000000000000 
0x0000000130040920:  0x0000000000000000  0x0000000100dcc180  
0x0000000130040930:  0x0000000000000000  0x0000000000000000 
0x0000000130040940:  0x0000000000000000  0x0000000000000000 
0x0000000130040950:  0x0000000000000000  0x0000000000000000 
0x0000000130040960:  0x0000000000000000  0x0000000000000000 
0x0000000130040970:  0x0000000000000000  0x0000000000000000 
0x0000000130040980:  0x0000000130040910  0x0000000000000000 
0x0000000130040990:  0x0000000000000000  0x0000000000000000 
0x00000001300409a0:  0x0000000000000330  0x00000001300409b0 
0x00000001300409b0:  0x000000010108e3c8  0x0000000092000007 
0x00000001300409c0:  0x000000010108e3b8  0x00000001010e4880 
0x00000001300409d0:  0x000000000006dd90  0x00000001010030c0 
runtime.throw({0x100f35dbf?, 0x130044000?})
        /usr/local/go/src/runtime/panic.go:992 +0x50
runtime.noSignalStack(0x10)
        /usr/local/go/src/runtime/signal_unix.go:994 +0x60
runtime.adjustSignalStack(0x10, 0x1010f85c0, 0x130040798)
        /usr/local/go/src/runtime/signal_unix.go:575 +0x24c
runtime.sigtrampgo(0x10, 0x130040910, 0x130040978)
        /usr/local/go/src/runtime/signal_unix.go:467 +0x174
runtime.sigtrampgo(0x10, 0x130040910, 0x130040978)
        :1 +0x1c
runtime: unexpected return pc for runtime.sigtramp called from 0x1df14ad48
stack: frame={sp:0x130040810, fp:0x1300408e0} stack=[0x1300386f0,0x130040af0)
0x0000000130040710:  0x0000000130040768  0x0000000000000000 
0x0000000130040720:  0x0000000000000000  0x0000000000000000 
0x0000000130040730:  0x0000000000000000  0x0000000000000000 
0x0000000130040740:  0x0000000000000000  0x0000000000000000 
0x0000000130040750:  0x0000000000000004  0x00000001300407d8 
0x0000000130040760:  0x0000000100dde16c   0x0000000100000010 
0x0000000130040770:  0x00000001010f85c0  0x0000000130040798 
0x0000000130040780:  0x0000000000000000  0x0000000000000000 
0x0000000130040790:  0x0000000000000000  0x0000000000000000 
0x00000001300407a0:  0x0000000000000000  0x0000000000000000 
0x00000001300407b0:  0x0000000000000000  0x0000000000000000 
0x00000001300407c0:  0x00000001300021a0  0x0000000130040910 
0x00000001300407d0:  0x0000000130040978  0x0000000130040808 
0x00000001300407e0:  0x0000000100ddd7c4   0x0000000000000010 
0x00000001300407f0:  0x0000000130040910  0x0000000130040978 
0x0000000130040800:  0x0000000000000000  0x0000000130040900 
0x0000000130040810: <0x00000001df14ad48  0x0000000000000010 
0x0000000130040820:  0x0000000130040910  0x0000000130040978 
0x0000000130040830:  0x855ee83f1200706a  0x0000000130040978 
0x0000000130040840:  0x00000001f685d000  0x00000001011292f4 
0x0000000130040850:  0x0000000000000000  0x0000000000000000 
0x0000000130040860:  0x0000000000000000  0x00000001010dff80 
0x0000000130040870:  0x0000000100f8b670  0x00000001300021a0 
0x0000000130040880:  0x0000000130040808  0x0000000000000000 
0x0000000130040890:  0x0000000000000000  0x0000000000000000 
0x00000001300408a0:  0x0000000000000000  0x0000000000000000 
0x00000001300408b0:  0x0000000000000000  0x0000000000000000 
0x00000001300408c0:  0x0000000000000000  0x0000000000000000 
0x00000001300408d0:  0x0000000000000000  0x0000000000000000 
0x00000001300408e0: >0x00000001011292f4  0x0000000000000003 
0x00000001300408f0:  0x000000000000007d  0x0000000130040f58 
0x0000000130040900:  0x0000000130040d58  0x0000000100daf4fc  
0x0000000130040910:  0x0000000000000010  0x0000000000000000 
0x0000000130040920:  0x0000000000000000  0x0000000100dcc180  
0x0000000130040930:  0x0000000000000000  0x0000000000000000 
0x0000000130040940:  0x0000000000000000  0x0000000000000000 
0x0000000130040950:  0x0000000000000000  0x0000000000000000 
0x0000000130040960:  0x0000000000000000  0x0000000000000000 
0x0000000130040970:  0x0000000000000000  0x0000000000000000 
0x0000000130040980:  0x0000000130040910  0x0000000000000000 
0x0000000130040990:  0x0000000000000000  0x0000000000000000 
0x00000001300409a0:  0x0000000000000330  0x00000001300409b0 
0x00000001300409b0:  0x000000010108e3c8  0x0000000092000007 
0x00000001300409c0:  0x000000010108e3b8  0x00000001010e4880 
0x00000001300409d0:  0x000000000006dd90  0x00000001010030c0 
runtime.sigtramp()
        /usr/local/go/src/runtime/sys_darwin_arm64.s:243 +0x74


goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /usr/local/go/src/runtime/asm_arm64.s:1259 +0x4 fp=0x13005bfe0 sp=0x13005bfe0 pc=0x100ddcaf4


goroutine 1 [running, locked to thread]:
        goroutine running on other thread; stack unavailable
* thread #2, stop reason = signal SIGABRT
    frame #0: 0x00000001bebf69e8 libsystem_kernel.dylib`__pthread_kill + 8
libsystem_kernel.dylib`__pthread_kill:
->  0x1bebf69e8 <+8>:  b.lo   0x1bebf6a04               ; <+36>
    0x1bebf69ec <+12>: stp    x29, x30, [sp, #-0x10]!
    0x1bebf69f0 <+16>: mov    x29, sp
    0x1bebf69f4 <+20>: bl     0x1bebf2670               ; cerror_nocancel
Target 0: (Runner) stopped.
Installing and launching...                                        21.5s
Error launching application on iPhone.

iOS example app runs fine up to version 1.17.8
After upgrading to 1.18, building the framework, app launch failed.

Reverting to 1.17.8, and rebuilding the framework, app launch succeeds.

I saw a similar error log posted here: #47952

@gopherbot gopherbot added the mobile Android, iOS, and x/mobile label Mar 18, 2022
@gopherbot gopherbot added this to the Unreleased milestone Mar 18, 2022
@changkun
Copy link
Member

Which iOS version are you using (Go 1.18 requires iOS12 or later)? Could you provide a minimum reproducible example?

@kstanmartin
Copy link
Author

kstanmartin commented Mar 18, 2022

I currently set on iOS 14.0 for the minimum version. The device I'm testing it on runs on iOS 15.1.
Okay, I'll try to setup something.

@changkun
Copy link
Member

I suspect that iOS 15 might have issues with code signing. Is the problem reproducible on iOS 14?

@kstanmartin
Copy link
Author

I currently don't have a device that runs iOS 14.
However, it's the same device and iOS version i used when testing the 1.17.8 compiled framework and the app runs without issues.

@changkun
Copy link
Member

If that's the case, then a reproducible example would be very helpful.

@changkun
Copy link
Member

JFYI: I am not able to reproduce this crash using the examples mentioned in #47952.

@kstanmartin
Copy link
Author

kstanmartin commented Mar 18, 2022

I tried to create a minimal example. In doing so I realized that I was using an older version of the gomobile binary.
For example, earlier, in running the command:

$ gomobile bind -target=ios -o Frameworks/helper.framework

In the latest version, it should have thrown the error:

gomobile: static framework name "Frameworks/helper.framework" missing .xcframework suffix

Furthermore, I noticed that the go.mod file has the maximum go version, but simply editing it to the new version didn't work.

module example.com/helper
 
go 1.17
...

So I reinitialize the the go module:

$ go mod init example.com/helper 

so that it reflects the current version:

module example.com/helper
 
go 1.18
...

In the end, I wasn't able to create a minimal example that can reproduce the error,
But I was able to solve my current predicament by:

  1. Reinitializing the go module.
  2. Updating gomobile.

Thank you for your support.

@changkun
Copy link
Member

Thanks for posting a solution. Based on the discussion, I think this issue does not require any action to take at the moment, and the issue might already have had a relevant Go 1.18 fix landed therefore upgrading to the latest gomobile can solve the issue. If anyone encountered a similar issue, we could refer to your suggested solution. Hence, close.

@tmm1
Copy link
Contributor

tmm1 commented Mar 28, 2022

I experience a similar error using cross-compiled golang for iOS (not via x/mobile), and the issue was due to GOOS=darwin instead of GOOS=ios on my compiles. This change in behavior started with https://go-review.googlesource.com/c/go/+/256917/

GOOS=ios was introduced in a413908

For catalyst, x/mobile still uses GOOS=darwin https://github.com/golang/mobile/blob/fea317f4e1ac8a39cd725d852b60936f25f2b23d/cmd/gomobile/env.go#L63-L65

@changkun
Copy link
Member

@tmm1 Have you tried to use the latest gomobile?

@stan-sack
Copy link

im still seeing this on go 1.19 when trying to build and install the basic example to the simulator following the steps here:

My env

  • go version: 1.19.2
  • simulator: ios 15.5
  • gomobile: v0.0.0-20221020085226-b36e6246172e

Repro steps

go install golang.org/x/mobile/cmd/gomobile@latest
gomobile build -target=iossimulator -bundleid=<my-bundle> -iosversion=15 golang.org/x/mobile/example/basic
  1. drag and drop basic.app folder onto the simulator
  2. open basic app

logs:

Error generating launch image for com.<my-bundle>: <XBLaunchImageError: 0x6000009c1a40; domain: XBLaunchStoryboardErrorDomain; code: 1; reason: "No such interface found.">

@stan-sack
Copy link

I tried @kstanmartin's solution from here. I checked out the basic example and reinitialised it with go1.19. This didnt fix it.

I also tried downgrading the simulator to ios 14.0.1 but now I cant even install the bundle on the simulator. I just get error: The system version is lower than the minimum OS version specified for bundle at ~/Library/Developer/CoreSimulator/Devices/<ID>/data/Library/Caches/com.apple.mobile.installd.staging/temp.CQojUs/extracted/Basic.app. Have 14.0.1; need 15.5. This happens regardless of whether or not I build with -iosversion=13, -iosversion=14, -iosversion=15 or no flag at all.

Not sure if its relevant but im on a M1 mac.

@albyok
Copy link

albyok commented Jan 25, 2023

I experience a similar error using cross-compiled golang for iOS (not via x/mobile), and the issue was due to GOOS=darwin instead of GOOS=ios on my compiles. This change in behavior started with https://go-review.googlesource.com/c/go/+/256917/

GOOS=ios was introduced in a413908

For catalyst, x/mobile still uses GOOS=darwin https://github.com/golang/mobile/blob/fea317f4e1ac8a39cd725d852b60936f25f2b23d/cmd/gomobile/env.go#L63-L65

This solved the problem for me

@ZaneCode6574
Copy link

I experience a similar error using cross-compiled golang for iOS (not via x/mobile), and the issue was due to GOOS=darwin instead of GOOS=ios on my compiles. This change in behavior started with https://go-review.googlesource.com/c/go/+/256917/

GOOS=ios was introduced in a413908

For catalyst, x/mobile still uses GOOS=darwin https://github.com/golang/mobile/blob/fea317f4e1ac8a39cd725d852b60936f25f2b23d/cmd/gomobile/env.go#L63-L65

Thank you. This helped me a lot.

@antonimmo
Copy link

I experience a similar error using cross-compiled golang for iOS (not via x/mobile), and the issue was due to GOOS=darwin instead of GOOS=ios on my compiles. This change in behavior started with https://go-review.googlesource.com/c/go/+/256917/

GOOS=ios was introduced in a413908

For catalyst, x/mobile still uses GOOS=darwin https://github.com/golang/mobile/blob/fea317f4e1ac8a39cd725d852b60936f25f2b23d/cmd/gomobile/env.go#L63-L65

This also made my day! Thanks so much for pointing it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile
Projects
None yet
Development

No branches or pull requests

8 participants