Closed Peter-Warlock closed 1 week ago
Hi and thanks for the report!
That's strange, I can run the demo on a simulator with the latest 1.2.0
just fine. I can't test it on a real device though, but I guess if that would be the same problem as you described it would crash no matter where.
It would be good to see the whole log. Can you please make a very simple test, just like placing the basis texture loading at the very top of the application listener's create()
:
public class App extends ApplicationAdapter {
@Override
public void create() {
Gdx.app.setLogLevel(Application.LOG_DEBUG);
new Texture(new Ktx2TextureData(Gdx.files.internal("test_texture.ktx2")));
}
}
And if it crashes, please post the whole log since the app start.
Also just in case, a dumb question, do you have the iOS natives dependency in your roboVM Gradle module?
runtimeOnly "com.crashinvaders.basisu:basisu-wrapper:$gdxBasisuVersion:natives-ios"
I can run the demo on a simulator with the latest
1.2.0
just fine.
Did you mean 1.0.2
? I don't see 1.2.0
version.
Right now I tried to set version to 1.2.0
and got this error message:
Could not GET 'https://jitpack.io/com/crashinvaders/basisu/basisu-wrapper/1.2.0/basisu-wrapper-1.2.0.pom'. Received status code 401 from server: Unauthorized
So I think you just make a typo.
About the topic error. I think FirebaseCrashlytic catch a errors messages and that's why I see just the app exit.
Therefor, I created default simple, libGDX project by using official gdx-setup.jar
. Tried to run it on simulator with default JPG texture - it works fine. After that, I added dependencies, convert a texture into .basisu
format and try to run it again.
And now I received full stack of the crash:
2023-11-28 10:29:46.922 IOSLauncher[5570:92453] [debug] IOSApplication: iOS version: 16.2
2023-11-28 10:29:46.922 IOSLauncher[5570:92453] [debug] IOSApplication: Running in 64-bit mode
2023-11-28 10:29:46.932 IOSLauncher[5570:92453] [debug] IOSApplication: Pixels per point: 2.0
2023-11-28 10:29:46.966 IOSLauncher[5570:92453] [debug] IOSApplication: Status bar is not visible
2023-11-28 10:29:46.966 IOSLauncher[5570:92453] [debug] IOSApplication: Computed bounds are x=0 y=0 w=375 h=667 bbW= 750 bbH= 1334
2023-11-28 10:29:47.017 IOSLauncher[5570:92453] [debug] IOSGraphics: Display: ppi=264, density=1.65
2023-11-28 10:29:47.726 IOSLauncher[5570:92453] [debug] IOSApplication: created
2023-11-28 10:29:47.728 IOSLauncher[5570:92453] [info] Test: Supported texture formats: [8c00, 8c01, 8c02, 8c03]
java.lang.UnsatisfiedLinkError: com.crashinvaders.basisu.wrapper.BasisuWrapper.basisValidateHeader(Ljava/nio/Buffer;)Z
at com.crashinvaders.basisu.wrapper.BasisuWrapper.basisValidateHeader(Native Method)
at com.crashinvaders.basisu.gdx.BasisuData.<init>(BasisuData.java:43)
at com.crashinvaders.basisu.gdx.BasisuData.<init>(BasisuData.java:32)
at com.crashinvaders.basisu.gdx.BasisuTextureData.prepare(BasisuTextureData.java:137)
at com.badlogic.gdx.graphics.Texture.load(Texture.java:156)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:147)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:142)
at com.babisu.test.MyGdxGame.create(MyGdxGame.java:37)
at com.badlogic.gdx.backends.iosrobovm.IOSApplication.didFinishLaunching(IOSApplication.java:157)
at com.badlogic.gdx.backends.iosrobovm.IOSApplication$Delegate.didFinishLaunching(IOSApplication.java:63)
at com.badlogic.gdx.backends.iosrobovm.IOSApplication$Delegate.$cb$application$didFinishLaunchingWithOptions$(IOSApplication.java)
at org.robovm.apple.uikit.UIApplication.main(Native Method)
at org.robovm.apple.uikit.UIApplication.main(UIApplication.java:433)
at com.babisu.test.IOSLauncher.main(IOSLauncher.java:19)
com.babisu.test: 5570
Process finished with exit code 0
I added some piece of code from your demo, to get supported textute formats.
Here the zip-file with that test project. basisu-test.zip You can try it on your side and detect the reason of this crash.
Thanks for the project provided.
Very strange to say the least. I tried the project on my iOS simulator and it works fine.
2023-11-28 01:10:43.250 IOSLauncher[1081:9783] [debug] IOSApplication: iOS version: 16.4
2023-11-28 01:10:43.250 IOSLauncher[1081:9783] [debug] IOSApplication: Running in 64-bit mode
2023-11-28 01:10:43.355 IOSLauncher[1081:9783] [debug] IOSApplication: Pixels per point: 3.0
2023-11-28 01:10:43.522 IOSLauncher[1081:9783] [debug] IOSApplication: Status bar is not visible
2023-11-28 01:10:43.522 IOSLauncher[1081:9783] [debug] IOSApplication: Computed bounds are x=0 y=0 w=390 h=844 bbW= 1170 bbH= 2532
2023-11-28 01:10:43.553 IOSLauncher[1081:9783] [debug] IOSGraphics: Display: ppi=264, density=1.65
2023-11-28 01:10:43.731 IOSLauncher[1081:9783] [debug] IOSApplication: created
2023-11-28 01:10:43.733 IOSLauncher[1081:9783] [info] Test: Supported texture formats: [8c00, 8c01, 8c02, 8c03]
[basisu_wrapper.cpp] INFO: Basis Universal 01.16
[basisu_wrapper.cpp] INFO: Initializing global basisu parser.
2023-11-28 01:10:43.764 IOSLauncher[1081:9783] [debug] BasisuTextureData: [badlogic.basis] Transcoding to the PVRTC1_4_RGB format
2023-11-28 01:10:43.767 IOSLauncher[1081:9783] [debug] BasisuTextureData: [badlogic.basis] Transcoded texture size: 32kB
2023-11-28 01:10:44.028 IOSLauncher[1081:9783] [debug] IOSApplication: Status bar is not visible
2023-11-28 01:10:44.028 IOSLauncher[1081:9783] [debug] IOSApplication: Computed bounds are x=0 y=0 w=390 h=844 bbW= 1170 bbH= 2532
2023-11-28 01:10:44.170 IOSLauncher[1081:9783] [debug] IOSApplication: resumed
2023-11-28 01:12:09.537 IOSLauncher[1081:9783] [debug] IOSApplication: paused
2023-11-28 01:12:12.095 IOSLauncher[1081:9783] [debug] IOSApplication: disposed
By looking at your stack trace, UnsatisfiedLinkError
means something is wrong with the native library. It probably is not loaded or is loaded, but the method signature doesn't match. Also, the missing of these two log lines in your log tells that the problem is with the initialization of Basis library and not with this particular texture.
[basisu_wrapper.cpp] INFO: Basis Universal 01.16
[basisu_wrapper.cpp] INFO: Initializing global basisu parser
At this point, I was only tested the library on my macOS virtual machine. Probably on the real hardware the natives behave differently. I'll try to do some more tests and try to reproduce the crash.
Hmmm, it's very strange. I also test it on virtual macOS. :) But as I said before, I tried to upload game on real device by TestFlight and it also crashed. So it doesn't' work on real device also as on my virual os + ios simulator. :) In my test game, I log after every line of code and see the next:
BasisuNativeLibLoader.loadIfNeeded();
FileHandle file = Gdx.files.internal("textures/checkered256.basis");
Gdx.app.log(TAG, "Reading Basis file: " + file.name());
ByteBuffer basisuData = BasisuGdxUtils.readFileIntoBuffer(file);
Gdx.app.log(TAG, "Reading Basis file: done");
boolean valid = BasisuWrapper.basisValidateHeader(basisuData); // <---- Here crash happened.
Gdx.app.log(TAG, "Data is " + (valid ? "valid" : "invalid"));
I.e. seems like some Basisu* functions works but BasisuWrapper.basisValidateHeader
crash the app. As crash log says it: (Ljava/nio/Buffer;)
My macOS: 12.7.1 (Monterey) My iOS Simulator test device: iPhone SE 3rd Gen with iOS 16.2 My MobiVM plugin for Android Studio is: 2.3.20 (the latest)
I.e. seems like some Basisu* functions works but BasisuWrapper.basisValidateHeader crash the app. As crash log says it: (Ljava/nio/Buffer;)
No, actually BasisuWrapper.basisValidateHeader(basisuData)
is the first line where the real native Basis Universal kicks in. There are many things that happen during that first call, including the native library load if it wasn't loaded, subsequent native Basis Universal initialization, and only then manipulation with the image data.
As I mentioned before, from the log it's most likely that the native library failed to load, so it might be not related to Basis in general. Hard to tell more at this point, I need to reproduce the crash.
One thing you could try is to download the project and run the demo. See if it behaves the same way.
git clone https://github.com/crashinvaders/gdx-basis-universal
cd gdx-basis-universal
./gradlew demo:ios:launchIPhoneSimulator
including the native library load if it wasn't loaded
I called BasisuNativeLibLoader.loadIfNeeded();
before this line and it completes without errors.
Ok. I did what you said:
Mac-Admin:~ admin$ cd /Users/admin/Documents/asprojects
Mac-Admin:asprojects admin$ git clone https://github.com/crashinvaders/gdx-basis-universal
Cloning into 'gdx-basis-universal'...
remote: Enumerating objects: 2713, done.
remote: Counting objects: 100% (71/71), done.
remote: Compressing objects: 100% (53/53), done.
remote: Total 2713 (delta 34), reused 51 (delta 18), pack-reused 2642
Receiving objects: 100% (2713/2713), 3.22 MiB | 527.00 KiB/s, done.
Resolving deltas: 100% (1045/1045), done.
Mac-Admin:asprojects admin$ cd gdx-basis-universal
Mac-Admin:gdx-basis-universal admin$ ./gradlew demo:ios:launchIPhoneSimulator
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
Mac-Admin:gdx-basis-universal admin$
I visited http://www.java.com. Downloaded and installed Java for MasOS on Intel Processor. and ran command again.
Mac-Admin:gdx-basis-universal admin$ ./gradlew demo:ios:launchIPhoneSimulator
Welcome to Gradle 8.3!
Here are the highlights of this release:
- Faster Java compilation
- Reduced memory usage
- Support for running on Java 20
For more details see https://docs.gradle.org/8.3/release-notes.html
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
Configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':demo'.
> Could not resolve all files for configuration ':demo:classpath'.
> Could not resolve com.android.tools.build:gradle:8.1.0.
Required by:
project :demo
> No matching variant of com.android.tools.build:gradle:8.1.0 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.3' but:
- Variant 'apiElements' capability com.android.tools.build:gradle:8.1.0 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.3')
- Variant 'javadocElements' capability com.android.tools.build:gradle:8.1.0 declares a component for use during runtime, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '8.3')
- Variant 'runtimeElements' capability com.android.tools.build:gradle:8.1.0 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.3')
- Variant 'sourcesElements' capability com.android.tools.build:gradle:8.1.0 declares a component for use during runtime, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '8.3')
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.3/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 14s
Mac-Admin:gdx-basis-universal admin$
So, as you can see - it failed to build and run.
Maybe you can make snapshot version with extra debug info and log output in BasisuWrapper.basisValidateHeader()
and I can try it on my side.
Just in case, maybe it matters I have installed XCode 14.2 (14C18)
Very strange to say the least. I tried the project on my iOS simulator and it works fine. https://github.com/crashinvaders/gdx-basis-universal/issues/4#issuecomment-1829482985
As I see, you used simulator with iOS 16.4. I used simulator with iOS 16.2. I checked it in XCode and it's no available simulator higher that my 16.2 on my MacOS (12.7.1)
The same things on MacOS (13.2 Ventura). 16.2 is a highest available iOS Simulator for that XCode v14.2 (14C18), that available for that MacOS.
My real device, where I also got a crash is iPhone SE with iOS 15,8.
So, I think you just used some modern thing that have no backward compatibility at building basisu-wrapper.framework. The simplest way: Try to download iOS Simulator 16.2 and run on it my basisu-test (from this issue). If it will works - you need a virtual machine with older MacOS (12.-13.) with older XCode to re-build your basisu-wrapper.framefork
Hi, I'm terribly sorry, totally missed your previous message.
The Gradle issues most likely happen because you don't have Android SDK installed. But just for the sake of desktop/iOS tests, you can simply comment out the demo Android module line in the settings.gradle
file at the root of the project:
rootProject.name = 'gdx-basis-universal'
// include ':demo:android' <--- Like this.
include ':demo:core'
include ':demo:desktop'
include ':demo:ios'
include ':demo:web'
include ':demo'
include ':basisu-wrapper'
include ':basisu-gdx'
include ':basisu-gdx-gwt'
It also can be related to the Java version. Which one you installed on the macOS machine (java --version
)? I remember I had issues on other projects with specific Gradle versions that refused to work with too old or too fresh Java (JDK <11 or >17). It's unlikely the case here, but worth checking.
And just in case here's a fat jar. (unzip it) It's heavy due to it contains natives for all the desktop targets, so it should run anywhere. Just like
java -jar gdx-basis-universal-demo-986302f.jar
So, I think you just used some modern thing that have no backward compatibility
Good point, probably, I should use some extra compiler flags for that. I'll test it on older simulators. If it crashes there, it's a clear indication of native incompatibility.
The Gradle issues most likely happen because you don't have Android SDK installed.
I have it. But anyway I tried to comment it and it's doesn't help.
It's heavy due to it contains natives for all the desktop targets, so it should run anywhere.
To what end? The problem is with the iOS version of basisu, not the desktop version.
I did the following:
So I don't understand how or why you can run it on your side without error.
As I said earlier, if you make some snapshot version of your library with the most detailed log of BasisuWrapper.basisValidateHeader function execution, then I can run it on my side and maybe that way we will understand the reason.
Or you have to get a new, clean virtual machine, do all the steps I described above and try to execute them in it.
Is there any chance that the bug will be fixed? Or the project is abandoned in the "as is" stage?
Hello! Sorry, but I have too little time to work on this project ATM and haven't tested other macOS VMs yet. But from what I can see, one iOS game I built and deployed with this library works quite stable and without issues for the last 4 months.
I have plans to finalize the mipmap features and update to the latest libs for the project sometime this month. Will try to set up a new virtual macOS and see if I can catch the error. So please go ahead and share anything else related to the bug if that might help to reproduce it.
BTW, which exact macOS VM project should I try?
But from what I can see, one iOS game I built and deployed with this library works quite stable and without issues for the last 4 months.
It can only be in one case: You forgot to mention some library, framework or settings that is available and used on your machine, on which you built your Basisu library and which is not on mine.
As I have shown before - the simplest project I created crashes on my machine (both in the simulator and on the device) and works fine on yours, on the developer's machine where you built your Basisu library.
It can't be anything but missing some important component at building.
BTW, which exact macOS VM project should I try?
I already said what and how to do here: https://github.com/crashinvaders/gdx-basis-universal/issues/4#issuecomment-1842232808 the only things was changed by time is newest version of XCode, Android Studio and MobiVM plugin.
Hello again! So I finally tried to make a clean install of macOS VM to test the library. So far, it works without issues. I made two clean installs of OSX-KVM Ventura on two different Linux (Pop!_OS) machines. I only follow the https://github.com/kholia/OSX-KVM README guide and install the necessary software using Homebrew.
Pop!_OS 22.04 LTS x86_64 (on Intel i7 based systems). Ventura 13.6.6 Xcode 15.2
Here's a barebones project I tested on (I tested this repo's demo too) - https://github.com/metaphore/basisu-test
Here are the full steps:
XCode > Settings > Locations > Command Line Tools
dropdown and accept the dialog)./bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
git, openjdk (v21)
)
brew install git openjdk
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
git clone https://github.com/metaphore/basisu-test
cd basisu-test
./gradlew ios:launchIPhoneSimulator
And that's it. Worked for both of my attempts.
Here's the app log:
IOSLauncher [debug] IOSApplication: iOS version: 17.2
IOSLauncher [debug] IOSApplication: Running in 64-bit mode
IOSLauncher [debug] IOSApplication: Pixels per point: 3.0
IOSLauncher [debug] IOSApplication: Status bar is not visible
IOSLauncher [debug] IOSApplication: Computed bounds are x=0 y=0 w=393 h=852 bbW= 1179 bbH= 2556
IOSLauncher Can't get Metal device. Metal Display won't be available.
IOSLauncher MGLKViewController resume
IOSLauncher [debug] IOSGraphics: Display: ppi=264, density=1.65
IOSLauncher [debug] IOSApplication: created
[basisu_wrapper.cpp] INFO: Basis Universal 01.16
[basisu_wrapper.cpp] INFO: Initializing global basisu parser.
IOSLauncher [debug] Ktx2TextureData: [libgdx.ktx2] Transcoding to the ETC2_RGBA format
IOSLauncher [debug] Ktx2TextureData: [libgdx.ktx2] Transcoded texture size: 24kB
IOSLauncher [debug] BasisuTextureData: [libgdx.basis] Transcoding to the ETC2_RGBA format
IOSLauncher [debug] BasisuTextureData: [libgdx.basis] Transcoded texture size: 24kB
IOSLauncher [debug] IOSApplication: Status bar is not visible
IOSLauncher [debug] IOSApplication: Computed bounds are x=0 y=0 w=393 h=852 bbW= 1179 bbH= 2556
IOSLauncher [debug] IOSApplication: resumed
IOSLauncher MGLKViewController viewDidAppear
Notice that:
Can't get Metal device. Metal Display won't be available.
are OK and don't break the app.Could you please try the test project and the exact steps I described?
I don't use Linux, so I did steps starting from 4 (Open Terminal and install Homebrew) on my VM on Windows.
And yes it's works without crash on Sonoma 14.1.2 with XCode 15.3
But on the same VM, the test project that I sent to you here https://github.com/crashinvaders/gdx-basis-universal/issues/4#issuecomment-1842232808 did not works and crushes with the same error as before.
As I say before - this is a default libGDX project what was builded by gdx-setup.jar application. The only things I did: is add Basisu by your instructions and convert default .jpg image into .basis format. And I run it from Android Studio. I don't know why so happens, but it's crashes.
Tried to run my test gdx project (https://github.com/crashinvaders/gdx-basis-universal/issues/4#issuecomment-1842232808) by using terminal, by using the same command as on your - and it's works!!!
After that tried to run it from Android Studio - and received the same crash.
I don't understand why the same project works from terminal and crushes from Android Studio.
I continue testing...
If i run my basisu-test from Terminal by ./gradlew ios:launchIPhoneSimulator
it build in folder :
\basisu-test\ios\build\robovm.tmp
If I run it from Android Studio it build in folder : \basisu-test\ios\robovm-build\tmp\iPhone 15 - 17.4\ios\x86_64-simulator
So we can compare generated files. If we compare config.xml file we can see (as I think) the main difference. Worked version (from Terminal) has
I tried to put this line in robovm.xml file - but got error at building time.
As I understood, Android Studio uses MobiVM plugin to build iOS app. That uses by terminal command - I don't know. But seems like this is a problem. gdx-basis-universal - did not linked in Android Studio. May be it have to be added by some other way.
I removed binary result files from folders because it's too big and I can't attach archive, all other files can show you what I said and you can test it on your side. basisu-test 4.zip
Finally I found the reason and can run the demo without crash from Android Studio.
The reason is: runtimeOnly
that described in your "Using the library" -> iOS module (RoboVM backend) section.
https://github.com/crashinvaders/gdx-basis-universal#ios-module-robovm-backend
I just replaced it by implementation
and now it runs without crash!
Here the result with runtimeOnly
(you can see it in dependencies section on screen)
Here the result with implementation
Amazing find! My god, it was all that simple!
I don't really know why it behaves that inconsistently. To my knowledge, IntelliJ Idea/Android Studio uses the same Gradle RoboVM plugin/Gradle tasks to assemble iOS builds. And to be honest, I don't think there's any reason for runtimeOnly
configuration to be there instead of implementation
. I only put it there because it looked to me like it's a lighter version of implementation
and is sufficient for the native artifact dependency.
Anyways, I'll update the readme and replace those dependency keywords. And thanks a lot for digging on it!
Hi,
Tried to use Basisu/KTX2 on iOS. But app just closed at loading Basisu texture on iOS Simulator and real iPhone device.
Log event "after load Basisu texture" never happened. The app is just close himself. Try it with "gdx-backend-robovm" and with "gdx-backend-robovm-metalangle" with the same result. With second one also got this text in log: