Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

pressing the back button, and then reopening causes hang #172

Closed
tiby312 opened this issue Jan 28, 2018 · 5 comments
Closed

pressing the back button, and then reopening causes hang #172

tiby312 opened this issue Jan 28, 2018 · 5 comments
Labels

Comments

@tiby312
Copy link

tiby312 commented Jan 28, 2018

Pressing the android "back" button, and then opening the app again either by icon, or process list, causes the app to hang, or say "app has stopped"

@tomaka
Copy link
Contributor

tomaka commented Jan 29, 2018

That is unfortunately a consequence of the bad model of execution of winit.

@tiby312
Copy link
Author

tiby312 commented Jan 30, 2018

Hmm this also happens with the basic example even without using winit.

@tomaka tomaka added the bug label Jan 30, 2018
@tomaka
Copy link
Contributor

tomaka commented Jan 30, 2018

Yes, this crate was more or less designed in order to be used directly by winit (or rather glutin at the time). Therefore the design decisions of winit/glutin impacted it in a negative way.

@mb64
Copy link
Contributor

mb64 commented Jul 11, 2019

The main problem here is that Android is free to call onDestroy(), followed by onCreate(), without re-loading the library. This leads to main() being called twice, which rust really hates, complaining about e.g. trying to write to stdout after shutdown, along with other things.

I'm currently working on the EventLoop 2.0 Android implementation, and as part of that re-writing a lot of the glue. This includes changes such as a local version of android_native_app_glue, and potential modifications to it open up more possibilities for solving this issue. I have two proposed solutions:

Don't require the thread to die during onDestroy()

This would entail checking if it's alive in onCreate() and acting accordingly.

Pros: main() gets to keep running when possible
Cons: It feels wrong to not destroy things during onDestroy. Also, it can never send the Winit LoopDestroyed event (because it's impossible to know if it'll actually be destroyed)

dlopen() and dlclose() the Rust code during onCreate() and onDestroy()

Essentially resetting the static data between runs of main().

Pros: It seems more consistent to say that onCreate() always calls main(), rather than "it sometimes does, sometimes doesn't."
Cons: Weird dlopen() hackery because it's Android

I'm curious to know which of these people think is best, or if you have other suggestions.

@mb64
Copy link
Contributor

mb64 commented Jul 30, 2019

This is fixed by #223, which calls fn main() directly instead of through Rust's startup glue.

@mb64 mb64 closed this as completed Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants