Skip to content

x/mobile/app: gobind crash 'app.Run called on thread xxx, but app.init ran on xx' #27509

@ntop001

Description

@ntop001

Please answer these questions before submitting your issue. Thanks!

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

go version go1.11 darwin/amd64

Does this issue reproduce with the latest release?

YES.

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

GOARCH="amd64"
GOBIN="/Users/ntop/tools/go"
GOCACHE="/Users/ntop/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/ntop/workspace/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/t6/8417qy4n2zn3lb370499nrl00000gn/T/go-build892512347=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I'm building a Go game for iOS. I use GoMobile's x/mobile/app package to write the game, but I didn't use gomobile build to build an .app. Since gomobile build just build a simple iOS app, if I want to use more native features, that's impossible. So I use gomobile bind to build a .framework, and invoke the 'Start' function in XCode's main method. But it will result in the exception - 'gobind app.Run called on thread xxx, but app.init ran on xx'. In the 'Start' function, I did't use any go routines, just call app.Main() to start the game. I printed thread-id both in init function and the app.Main() function, the thread-id is truely different. It seems that the .framework built with gomobile will not init package in the same thread as the calling function.

What did you expect to see?

The .framework build with gomobile bind can work successfully in my iOS project.
PS: only code use x/mobile/app will crash, because the checking code stay there.

What did you see instead?

The app crashed and print the message as above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    mobileAndroid, iOS, and x/mobile

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions