JonasBernard / FakeStandby

An Android app for turning the screen off while keeping apps running.
https://fakestandby.jonasbernard.de
GNU General Public License v3.0
424 stars 27 forks source link

[BUG] App crashes when rotating the screen #30

Open davirec opened 2 years ago

davirec commented 2 years ago

When I perform these sequences of events, the app crashes when rotating the screen:

  1. Go to the Main activity
  2. Tap in Escape methods
  3. A form similar to this will appear

Before rotation:

  1. Force the pause from the activity and then return to the activity (double rotation). Note that the app crashes. Note: the pause from activity can be performed in several ways. We suggest using a double rotation (starts in portrait, goes to landscape, and back to portrait) with this function previously enabled in the smartphone.

The expected behavior is the return to the previous state with the form of the previous image.

However, the app crashes.

After rotation:

https://user-images.githubusercontent.com/3637419/157570593-0f98e5ca-32fa-4b8c-ae6a-595b87154fc3.mp4

Device:

JonasBernard commented 2 years ago

Hi Davi,

thanks for that issue! I could easily reproduce it but have absolutely no idea, where this comes from.

As you see in the commit history, I am currently not working on the app. This is because I have to much to do for university right now.

As soon as I can get back to working on the project, I will have a closer look on this.

davirec commented 2 years ago

Thanks

PeterKW commented 1 year ago

This is the crash report that I get when I reproduce on my end if that's of use @JonasBernard ?

FATAL EXCEPTION: main Process: android.jonas.fakestandby, PID: 17267 java.lang.RuntimeException: Unable to start activity ComponentInfo{android.jonas.fakestandby/android.jonas.fakestandby.settings.SettingsActivity}: java.lang.IllegalStateException: Target fragment must implement TargetFragment interface at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3636) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3793) at android.app.ActivityThread.handleRelaunchActivityInner(ActivityThread.java:5739) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5631) at android.app.servertransaction.ActivityRelaunchItem.execute(ActivityRelaunchItem.java:71) at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2211) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7894) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1009) Caused by: java.lang.IllegalStateException: Target fragment must implement TargetFragment interface at androidx.preference.a.onCreate(SourceFile:12) at u0.d.onCreate(Unknown Source:0) at androidx.fragment.app.Fragment.performCreate(Unknown Source:16) at androidx.fragment.app.q.U(SourceFile:13) at androidx.fragment.app.q.S(SourceFile:1) at androidx.fragment.app.q.T(Unknown Source:47) at androidx.fragment.app.q.w(Unknown Source:9) at androidx.fragment.app.q.m(Unknown Source:6) at androidx.fragment.app.e.onCreate(SourceFile:7) at h.d.onCreate(Unknown Source:10) at android.jonas.fakestandby.settings.SettingsActivity.onCreate(Unknown Source:0) at android.app.Activity.performCreate(Activity.java:8050) at android.app.Activity.performCreate(Activity.java:8030) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1330) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3609) ... 15 more

JonasBernard commented 1 year ago

I could reproduce this. It is of use, I hope. I will have a closer look at it. Sorry for the late reaction on that one.

sudomain commented 8 months ago

I was encountering this until I set up a workaround to:

  1. disable auto-rotate and then
  2. Enable FakeStandby

It's not convenient and it doesn't fix whatever the underlying issue it, but it works. Step 1 Could be done with any automation app that receives intents such as Automation or Key Mapper or even Termux. Step 2 can be done with apps that can send intents. In Termux: am start -n android.jonas.fakestandby/.actions.StartOverlay

In GUI based apps such as KeyMapper, these settings can be used: Screenshot_20240314-113758

Hope this helps someone also experiencing the auto-rotate crash

JonasBernard commented 8 months ago

That's actually a very nice solution :) Did not know anyone really uses my action StartOverlay.

sudomain commented 8 months ago

Is StartOverlay the only action to start FakeStandby?

Also, I might have spoken too soon because I had a crash this morning that I had to reboot from (the StopOverlay action which I also use in a script was not working). Here's hoping disabling auto rotate and then locking in portrait mode fixes it

JonasBernard commented 8 months ago

There is a StopOverlay Action too...not very surprising, I guess.

sudomain commented 8 months ago

Hmm so I had a crash again this morning: My stop_fakestandby script stopped working until a reboot. The device had auto-rotate turned off and was locked in portrait mode. The only things I had changed were:

  1. I deactivated the swipe up escape methoed, leaving 4 simultaneous touches activated.
  2. In settings I increased the time between when the screen turns off due to timeout/inactivity and when the screen locks

I don't think 2 was the cause, so hopefully leaving the swipe up escape method will prevent my crash.

Btw here is my stop_FakeStandby script that I run from within Termux:

#!/data/data/com.termux/files/usr/bin/sh                                                        

am start -n android.jonas.fakestandby/.actions.StopOverlay