Android MonoGame应用程序在恢复后立即关闭

问题描述 投票:0回答:1

使用MonoGame 3.7.1,我在Android上有一个非常基本的游戏设置。关闭/重新打开应用程序时出现一些奇怪的行为。

要退出游戏,我使用此逻辑:

if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
{
    Activity.MoveTaskToBack(true);
    //Exit(); //Originally was using this, neither seems to have changed much
}

但是,恢复应用程序时,它偶尔会(似乎是随机的)打开,然后立即关闭(不会崩溃)。它并不总是这样做,有时它会返回到先前的状态而没有任何问题。如果我再次尝试恢复它,它将正常打开。

我已经捕获了显示此行为here的视频。值得注意的是,没有崩溃发生。这是通过Visual Studio在Debug中运行的,并且通过USB连接了电话,因此如果发生崩溃我就知道了。即使不在调试模式下,也会发生此行为。

意外关闭发生时的调试输出是这样:

05-22 23:27:05.228 E/SensorManager(26381): registerListenerImpl sensorName:BMI160_ACCELEROMETER Accelerometer Non-wakeup,isWakeUpSensor:false,callingApp: TestGame.TestGame,callingPid:26381,callingUid:10569
05-22 23:27:05.245 D/DecorView(26381): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@8012b96[MainActivity]
05-22 23:27:05.265 W/monodroid-assembly(26381): typemap: unable to find mapping to a managed type from Java type 'com/google/android/gles_jni/EGLSurfaceImpl'
05-22 23:27:05.265 D/MonoGame(26381): GraphicsDeviceManager.ResetClientBounds: newClientBounds={X:0 Y:137 Width:1080 Height:1799}
05-22 23:27:05.265 D/AudioTrack(26381): ClientUid 10569 AudioTrack::start 
05-22 23:27:05.317 E/SensorManager(26381): unregisterListenerImpl callingApp: TestGame.TestGame,callingPid:26381,callingUid:10569
05-22 23:27:05.325 D/        (26381): PlayerBase::stop() from IPlayer
05-22 23:27:05.325 D/AudioTrack(26381): ClientUid 10569 AudioTrack::stop 
05-22 23:27:05.325 D/AudioTrack(26381): stop(1656): called with 1772 frames delivered
Thread finished: <Thread Pool> #17
Thread started: <Thread Pool> #28

对我来说唯一突出的是typemap: unable to find mapping...GraphicsDeviceManager.ResetClientBoundsThread finished: <Thread Pool> #17行。

也就是说,当正确加载时出现类似消息时,这些可能完全不相关。

有什么想法吗?

c# xna monogame
1个回答
0
投票

我从未见过,但是我发现Android上涉及ResetClientBounds()的backbuffer / clientWindow的处理存在很多问题。

如果需要,您可以尝试修改后的版本,看看是否可以解决。您可以使用nugetinstaller

需要更改ScreenOrientation = ScreenOrientation.FullSensor在Activity1.cs中,否则将无法加载。

© www.soinside.com 2019 - 2024. All rights reserved.