termux / termux-x11

Termux X11 add-on application.
https://termux.dev
GNU General Public License v3.0
1.94k stars 301 forks source link

OpenXR - Switching between 2D and XR #676

Closed lvonasek closed 4 weeks ago

lvonasek commented 1 month ago

When user opens in the headset 2D preferences screen in XR mode then it behaves like two separate apps.

In this PR I did following changes:

twaik commented 1 month ago

No need to call teardown with broadcast. Simply make protected void teardown() {} in MainActivity, maketeardownprotected function with@Override` and it will be available from MainActivity...

lvonasek commented 1 month ago

No need to call teardown with broadcast. Simply make protected void teardown() {} in MainActivity, maketeardownprotected function with@Override` and it will be available from MainActivity...

I tried that, it didn't work.

twaik commented 1 month ago

It did not work with exception or it simply and silently ignored changes?

twaik commented 1 month ago

I am not so sure about this but it seems to me you should pass it to GLSurfaceView's thread with GLSurfaceView.queueEvent because it is not async.

twaik commented 1 month ago

And in clientConnectedStateChanged too.

lvonasek commented 1 month ago

It silently ignored the changes.

As far as I understand it. When I open the preference screen from the system notifications, it opens a new instance of the app which doesn't contain XrActivity.

twaik commented 1 month ago

That is correct, but why exactly you think it is related?

twaik commented 1 month ago

BradcastReceiver receiving notification about preferences changed is registered in runtime. So XrActivity receives it too.

lvonasek commented 1 month ago

It is like running two separate apps. The one with the preference screen doesn't contain instance of XrActivity.

I just tested this in XrActivity:

    @Override
    void onPreferencesChangedCallback() {
        if (oldXrMode != prefs.xrMode.get()) {
            Log.d("XXX", "XR=" + prefs.xrMode.get());
        }
        super.onPreferencesChangedCallback();
    }

and it isn't called.

twaik commented 1 month ago

It is weird.

  1. Only one activity should be available at the same time.
  2. Broadcast about preferences change should be sent to both activities. It is being broadcasted. Something is broken.
lvonasek commented 1 month ago
  1. Only one activity should be available at the same time.

It isn't possible to mix XR and 2D content in one activity. As I start the XrActivity another activity is created. In my point of view the behavior is expected.

  1. Broadcast about preferences change should be sent to both activities. It is being broadcasted. Something is broken.

I cannot say why the broadcast doesn't work. The XR behavior in Android apps isn't documented at all.