Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolset app crashes on trying to open to select archive #7174

Closed
2 tasks done
zenseii opened this issue May 13, 2023 · 17 comments · Fixed by #7175
Closed
2 tasks done

Toolset app crashes on trying to open to select archive #7174

zenseii opened this issue May 13, 2023 · 17 comments · Fixed by #7175
Labels
Android Android version of the engine. bug Something doesn't work
Milestone

Comments

@zenseii
Copy link
Collaborator

zenseii commented May 13, 2023

Preliminary checks

Platform

Android

Describe the bug

A user on Discord is reporting that the toolset app crashes without a message upon clicking on the option "extract homm2 assets" on their Android 7 tablet.

Version 1.0.3 worked fine.

Save file

No file.

Additional info

No response

@zenseii zenseii added the bug Something doesn't work label May 13, 2023
@zenseii zenseii added this to the 1.0.5 milestone May 13, 2023
@zenseii
Copy link
Collaborator Author

zenseii commented May 13, 2023

Hi, @oleg-derevenetz. I'll share anything else the user writes here. Do you have any suspicions to why this happens?
They have a phone which they are able to use without problems.

@Shadic93nh
Copy link

Well Hello its me who reported it. But yeah everything Zense writted is fine but it also count for game app itself it also crashes on start on 1.0.3 everything goes smooth

@oleg-derevenetz
Copy link
Collaborator

@zenseii If there is no error message at all, and the extraction works on (I suppose, a bit more modern) phone, but fails on the not-so-modern Android 7 tablet, then I suppose that it may be due to Android OOM (out-of-memory) killer. Does this archive contain homm2.gog file? If yes, what if the user will remove it from the archive?

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented May 13, 2023

@Shadic93nh if some resource file was extracted only partially (e.g. animation) and therefore is damaged, the game itself can fail naturally as well. Does it fail on the tablet only or on the phone as well?

@Shadic93nh
Copy link

Shadic93nh commented May 13, 2023

No Oleg on android 13 everything works as intended in both version but not on android 7 tablet which is a huawei mediapad m3 8inch lte on 1.0.3 tablet passes but after updated to 1.0.4 both are not wanting to work tablet has like 4 gb of memory. And no zip contains no homm2.gog as i had prepared all required files

@oleg-derevenetz
Copy link
Collaborator

@Shadic93nh then the same questions - does your HoMM2 archive contain homm2.gog file? If yes, what if you remove it from the archive?

@Shadic93nh
Copy link

Shadic93nh commented May 13, 2023

It doesnt like i sayed before. I didnt even tryed to add it as i extracted necessary files from it right to the game. Replying from said android 13 phone

@oleg-derevenetz
Copy link
Collaborator

I do not understand anything. What do you mean by "it"? What exactly happens if you try to extract the ZIP archive with the contents of original HoMM2 directory both on phone and on tablet? Does this archive contain homm2.gog file? What if you remove this file from the ZIP archive and try to extract the resulting archive both on phone and tablet?

@zenseii
Copy link
Collaborator Author

zenseii commented May 13, 2023

It doesnt like i sayed before. I didnt even tryed to add it as i extracted necessary files from it right to the game. Replying from said android 13 phone

Would you be able to provide a screenshot or names of the contents of the heroes 2 archive you have on your phone?

@Shadic93nh
Copy link

Sure here is content of my fheroes2 on phone
Screenshot_2023-05-13-22-05-14-36_2602b93dc3ef59eeb51bac049073361e

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented May 13, 2023

What these "901 MB / 1.36 GB" above mean? What is the size of this ZIP file? If it's the size of the ZIP file (packed size / full size), then it seems too big, because on my phone ZIP file from GOG (full content of GOG directory) takes just ~370 MB.

@Shadic93nh
Copy link

Shadic93nh commented May 13, 2023

Well it only contains files directory from pc version as i was unsure at first if i need it or not. But otherwise works fine and also i have a lot maps added just answering to not make you worried :B. But on tablet i deleted this files folder and it didnt make much difference on 1.0.4. to add without files i added cause i thought android had soundfonts too the whole zip is 379 mb 9mb of added maps

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented May 13, 2023

OK @Shadic93nh, @zenseii, I was able to borrow the ancient Lenovo tablet with Android 6, and was able to reproduce the issue. On that device it looks like this:

FATAL EXCEPTION: Thread-17106
Process: org.fheroes2, PID: 23939
java.lang.NoSuchFieldError: No instance field file of type Ljava/lang/String; in class Ljava/nio/file/FileSystemException; or its superclasses (declaration of 'java.nio.file.FileSystemException' appears in /data/app/org.fheroes2-1/base.apk:classes2.dex)
	at j$.desugar.sun.nio.fs.DesugarLinuxFileSystemProvider.createDirectory(SourceFile)
	at j$.nio.file.Files.createDirectory(SourceFile:0)
	at j$.nio.file.Files.createDirectories(SourceFile:0)
	at org.fheroes2.HoMM2AssetManagement.extractHoMM2AssetsFromZip(HoMM2AssetManagement.java:115)
	at org.fheroes2.ToolsetActivity$ToolsetActivityViewModel.lambda$extractAssets$0$org-fheroes2-ToolsetActivity$ToolsetActivityViewModel(ToolsetActivity.java:102)
	at org.fheroes2.ToolsetActivity$ToolsetActivityViewModel$$ExternalSyntheticLambda0.run(D8$$SyntheticClass)
	at java.lang.Thread.run(Thread.java:818)

So it's an issue with java.nio.* desugaring on older Android versions. Android Toolset I/O implementation was recently switched to Java New I/O (java.nio.* ), and desugaring is used (in other words, emulation) of this new API on older Android versions using special libs from Google. But these libs are relatively new and despite the following promises:

You are now free to use the java.nio APIs no matter which Android version is on the user’s device.

there are reports that some part of this emulation may not work on Android 7 or lower devices:

A few features however cannot be emulated for devices running Android 7 and lower and instead throw an instance of UnsupportedOperationException or return null.

so it looks like this very issue.

This emulation is a relatively new feature (this blog post was written in February 2023), so maybe it will be fixed later in more recent versions of these desugaring libs. We can wait until next release and if it will not be fixed, then we can either bump the minimum supported Android version to Android 8 or rewrite the relevant parts without NIO (what I personally would not like to do, because NIO is really handy).

@oleg-derevenetz
Copy link
Collaborator

oleg-derevenetz commented May 13, 2023

@Shadic93nh if you have Android SDK installed, you can try the following:

  • Enable developer mode and debugging over USB on your Android 7 tablet, connect it to your PC using USB cable;
  • Run adb logcat > logfile.log command (adb is located in the platform-tools subdirectory of the Android SDK directory);
  • Run the ZIP extraction process using the Android Toolset and wait for the crash;
  • Search the logfile.log for appropriate "FATAL EXCEPTION" (in the org.fheroes2 process) and post it here.

@oleg-derevenetz oleg-derevenetz added the Android Android version of the engine. label May 13, 2023
@oleg-derevenetz
Copy link
Collaborator

On Android 8 (I have my own old Sony Xperia X Compact device with Android 8) everything works just fine, so it seems that these desugaring issues are really observed only on devices with Android 7 or earlier.

@Shadic93nh
Copy link

I see. I might just wait or so for now.

@oleg-derevenetz
Copy link
Collaborator

It turns out that this issue is observed only with latest version of desugaring libs, but not with the previous one. I downgraded them from 2.0.3 to 2.0.2, and now everything works just fine on my Android 6 tablet.

@Shadic93nh could you please try to install the APK from here (it's in the fheroes2_android.zip archive) on your Android 7 tablet and test it? Please note that this is debug build signed by debug certificate, so you will need to uninstall the version from Google Play first, and, since it's a debug build, it is not optimized, so don't use it to evaluate the game performance on your tablet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Android version of the engine. bug Something doesn't work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants