Skip to content

x/mobile/app: Open(.) behavior in Java Activity #9422

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

Closed
jhleath opened this issue Dec 22, 2014 · 4 comments
Closed

x/mobile/app: Open(.) behavior in Java Activity #9422

jhleath opened this issue Dec 22, 2014 · 4 comments

Comments

@jhleath
Copy link

jhleath commented Dec 22, 2014

  1. Using the latest committed version of golang.org/x/mobile (just go get -u'd it), and a devel version of Go.
  2. Compiling on darwin/amd64 for android/arm.
  3. I was attempting to utilize golang.org/x/mobile/app.Open() in an net/http server response.
  4. I expected to get an open reference to the file or an error detailing why the file could not be opened.
  5. Instead, I get the following "interesting" error in logcat.

Logs:

I/GoStdio (18461): GET /Index.html on app.melange.127.0.0.1.xip.io:7776 app
I/GoStdio (18461): Opening file client /Index.html
I/GoStdio (18461): About to App.Open
I/WindowState(  530): WIN DEATH: Window{1d53fd00 u0 com.getmelange.melange/com.getmelange.melange.MainActivity}
E/libprocessgroup(  530): failed to kill 1 processes for processgroup 18461
I/ActivityManager(  530): Process com.getmelange.melange (pid 18461) has died
W/ActivityManager(  530): Force removing ActivityRecord{2f5aeb91 u0 com.getmelange.melange/.MainActivity t279}: app died, no saved state
I/ActivityManager(  530): Activity reported stop, but no longer stopping: ActivityRecord{71ab226 u0 com.android.launcher/com.android.launcher2.Launcher t27}

Searching around suggests that WIN DEATH is caused when the application stops responding. Through effective fmt.Println() debugging, I was able to determine that app.Open() does not return, but the WIN DEATH error is always triggered.

Note that I'm running the application on a Nexus 7 running Lollipop.

@jhleath
Copy link
Author

jhleath commented Dec 22, 2014

After rebuilding the Docker image, updating the mobile repo, and recompiling, I have found a new error message that may have something interesting log message.

I/GoStdio (18461): About to App.Open
E/JavaBinder(  530): !!! FAILED BINDER TRANSACTION !!!
I/WindowState(  530): WIN DEATH: Window{1d53fd00 u0 com.getmelange.melange/com.getmelange.melange.MainActivity}

I'm not entirely sure why the binder is getting involved in the app.Open(), but that seems to be the root of the issue. I will keep investigating.

@jhleath
Copy link
Author

jhleath commented Dec 23, 2014

I have isolated the problem. It appears when calling Go code from within an activity that is not a NativeActivity. Since onCreate is only called within android.go when utilizing a NativeActivity, the assetManager variable is not set.

I'm going to create a patch for my needs, but I'm not sure if this is something that is expected to be supported in general (calling app.Open(.) if you are not using a fully-native activity). Any thoughts?

@jhleath jhleath changed the title mobile: app.Open(.) behavior in non-main Goroutine mobile: app.Open(.) behavior in Java Activity Dec 23, 2014
@crawshaw crawshaw self-assigned this Dec 23, 2014
@crawshaw
Copy link
Member

This should work, so it's a bug. If you intend to send a CL please let me know, otherwise I'll take a look.

@jhleath
Copy link
Author

jhleath commented Dec 23, 2014

I don't expect to send a CL because of my limited knowledge of the JNI, so I would certainly appreciate you taking a look at it. Thanks!

@mikioh mikioh changed the title mobile: app.Open(.) behavior in Java Activity app: Open(.) behavior in Java Activity Jan 4, 2015
@mikioh mikioh changed the title app: Open(.) behavior in Java Activity x/mobile/app: Open(.) behavior in Java Activity Aug 5, 2015
@golang golang locked and limited conversation to collaborators Aug 5, 2016
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
Tested manually by modifying example/libhello to read an asset file,
and checking crawshaw's balloon app continues to work.

Fixes golang/go#9422.

Change-Id: I17b25d9456a4023c68be1de82ee071ea01299e68
Reviewed-on: https://go-review.googlesource.com/5680
Reviewed-by: David Crawshaw <crawshaw@golang.org>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
Tested manually by modifying example/libhello to read an asset file,
and checking crawshaw's balloon app continues to work.

Fixes golang/go#9422.

Change-Id: I17b25d9456a4023c68be1de82ee071ea01299e68
Reviewed-on: https://go-review.googlesource.com/5680
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants