hajimehoshi / ebiten

Ebitengine - A dead simple 2D game engine for Go
https://ebitengine.org
Apache License 2.0
11k stars 657 forks source link

ebiten: add `RunGameOptions.StrictContextRestoration` to use `internal/restorable` as an optional feature #3083

Closed hajimehoshi closed 1 month ago

hajimehoshi commented 1 month ago

Ebitengine Version

v2.8.0-alpha.3

Operating System

Go Version (go version)

go version go1.22.6 darwin/arm64

What steps will reproduce the problem?

Submit an Android application and see prelaunch reports

What is the expected result?

No error

What happens instead?

There are some errors.

This error sometimes happens in the prelaunch report (google Pixel 5 64-bit only), and also in the real world (Android vitals)

  #00  pc 0x0000000000052a64  /apex/com.android.runtime/lib64/bionic/libc.so (__memcpy_aarch64_simd+36)
  #01  pc 0x000000000017871c  /vendor/lib64/egl/libGLESv2_adreno.so (!!!0000!77df12deb6a622478efa8fb9929034!4783c89!+1212)
  #02  pc 0x000000000077f9c8  /data/app/~~QGOUdPYjXO_FBwGrhte-pA==/com.rpgsnack.tsugunai-zPiYGBu1D1mPh_UdnnjB1A==/split_config.arm64_v8a.apk

This error happens when resizing a window in an Android desktop emulator (Generic Small Desktop (x86) (virtual))

  #00  pc 0x0000000000057d51  /vendor/lib64/libGLESv2_enc.so (GL2Encoder::calcIndexRange(void const*, unsigned int, int, int*, int*)+609)
  #01  pc 0x000000000003dd30  /vendor/lib64/libGLESv2_enc.so (GL2Encoder::s_glDrawElements(void*, unsigned int, int, unsigned int, void const*)+832)
  #02  pc 0x000000000077b720  /data/app/~~EK_pBBRAksFg2bglyGOCaA==/com.rpgsnack.tsugunai-IznR2H8Wmy2OizfErqfZvA==/split_config.x86_64.apk

In order to fix them, I think we should revive internal/restorable unfortunately.

Anything else you feel useful to add?

internal/restorable was removed at #805

hajimehoshi commented 1 month ago

Note to myself: I'm not sure I should revert https://github.com/hajimehoshi/ebiten/commit/5a36b4bb48205676e37f0332e3e914df13c0d08d. IIUC, this is not needed for Android where you can detect context loss easily. See also a30f075896b76b2f6fb1536c490aead650e4157f

hajimehoshi commented 1 month ago

Note to myself: 771e5685f81ea6b1cad60a22423e56a8ae4ef874 is not needed to be reverted for Android.

hajimehoshi commented 1 month ago

Note to myself: I found appendRegionRemovingDuplicates is pretty heavy.

This was introduced at https://github.com/hajimehoshi/ebiten/commit/367606f2748ae383ec87e6fcc9c7bb3636228517 and optimized at https://github.com/hajimehoshi/ebiten/commit/cc247962703eba99eae732876496375191f16cbe, and this is still heavy. I think I'll remove them.

Related

hajimehoshi commented 1 month ago

In order to mitigate risk of performance regression, I have to add a feature to switch restoring or not.