Recent

Author Topic: BGRABitmap Thread Problem in Android  (Read 4314 times)

mercury

  • Full Member
  • ***
  • Posts: 154
BGRABitmap Thread Problem in Android
« on: August 17, 2017, 05:52:20 am »
Using BGRABitmap to load png file and SDL for display. Everything is good with or without thread on Windows. But with thread on Android, only get a whole black bitmap. Both emulator and real device show the same result.
Please help.

Tools:
FPC 3.0.2
BGRABitmap 9.5
Binutils 2.24.90
SDL 2.0.5

mercury

  • Full Member
  • ***
  • Posts: 154
Re: BGRABitmap Thread Problem in Android
« Reply #1 on: August 17, 2017, 05:53:01 am »
source code here

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1738
Re: BGRABitmap Thread Problem in Android
« Reply #2 on: August 17, 2017, 10:57:19 am »
Would you mind also make the libSDL2.a (and libSDL2.so for dynamic linking) available ?

I tried your app (with some SDL2 libs found on the I-net) on my Samsung S3. Did not work. But also did not crash or error out !

mercury

  • Full Member
  • ***
  • Posts: 154
Re: BGRABitmap Thread Problem in Android
« Reply #3 on: August 18, 2017, 10:57:46 am »
Would you mind also make the libSDL2.a (and libSDL2.so for dynamic linking) available ?
It’s not so hard to compile SDL for android.
Download NDK and run ndk-build in SDL source code directory. Even no need configure (which always get really annoying problem).
NDK : https://developer.android.com/ndk/downloads/index.html
SDL : https://libsdl.org/release/SDL2-2.0.5.tar.gz

I tried your app (with some SDL2 libs found on the I-net) on my Samsung S3. Did not work. But also did not crash or error out !
What is I-net? If you don’t want to use adb on your phone, you can check app.log in SDCard root directory.

Anyway, here is the lib I compiled, include armeabi, armeabi-v7a and x86. Don’t download them all, three mirrors are the same.
https://bdupload.info/segx2ih44ico
https://uploadocean.com/25akurfhuw6w
https://www.sendspace.com/file/ta5c6q



DonAlfredo

  • Hero Member
  • *****
  • Posts: 1738
Re: BGRABitmap Thread Problem in Android
« Reply #4 on: August 18, 2017, 11:50:08 am »
I-net = Internet  :)

I know that its not that hard to compile. I just want to use what you are using.
The less differences there are between our setups, the more likely an error is also shared between us.

Another question.

When compiling for Windows, compilation failed due to linking errors.
I solved them by adding some standard functions from here:
https://github.com/BeRo1985/pasvulkan/blob/master/src/PasVulkan.StaticLinking.pas
I was wondering if the archive you included with your first post compiles out-of-the-box on your system for Windows ?
If not, please include a fully functional project. Again, to prevent differences between our setups.

Thanks.

mercury

  • Full Member
  • ***
  • Posts: 154
Re: BGRABitmap Thread Problem in Android
« Reply #5 on: August 18, 2017, 01:55:05 pm »
I-net = Internet  :)
Is this abbreviate really used commonly?

When compiling for Windows, compilation failed due to linking errors.
I solved them by adding some standard functions from here:
https://github.com/BeRo1985/pasvulkan/blob/master/src/PasVulkan.StaticLinking.pas
I was wondering if the archive you included with your first post compiles out-of-the-box on your system for Windows ?
If not, please include a fully functional project. Again, to prevent differences between our setups.
Maybe you used a different compiler (change the static linked libs to fit compile you used should work). What I used is download from here:
https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/Personal Builds/mingw-builds/4.9.3/threads-posix/dwarf/

The source code I uploaded is fully functional project (yet not finished like sound/draw/etc.).
I uploaded the lib+bin I compiled for win32. (Three mirrors are the same.)
https://uploadocean.com/33gu9fh5ptro
https://www.sendspace.com/file/brb5aq
https://bdupload.info/udtquqau6z5p

With these libs you should compile the same binary as mine (and with FPC 3.0.2).

mercury

  • Full Member
  • ***
  • Posts: 154
Re: BGRABitmap Thread Problem in Android
« Reply #6 on: August 18, 2017, 02:28:49 pm »
I solved them by adding some standard functions from here:
https://github.com/BeRo1985/pasvulkan/blob/master/src/PasVulkan.StaticLinking.pas
This pasvulkan project is amazing! All thing I want -- cross-platform framework with Sprites/Audio/Canvas/Font/GUI. But I think neither my computer nor android device support vulkan. And I guest most people don’t have any device support it. May I can use this framework several years later. As now I better stuck with SDL2 which gives most compatibility (DirectX/OpenGL).

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1738
Re: BGRABitmap Thread Problem in Android
« Reply #7 on: August 18, 2017, 02:57:26 pm »
Quote
This pasvulkan project is amazing!

Yes. To be honest, with the Vulkan-link I was also hoping that you would have a look at the Vulkan project.
 :D

BeRo is an amazing programmer. And the structuring of his software is also very good !
You could use his SDL2 bindings and build your work upon them.
Later, you could easily switch over towards using Vulkan itself.

Thanks for sending the win32 project itself.
I will have another look.

edit
There are also other alternatives:
Castle Game Engine : https://github.com/castle-engine
PXL: https://sourceforge.net/projects/asphyre/

mercury

  • Full Member
  • ***
  • Posts: 154
Re: BGRABitmap Thread Problem in Android
« Reply #8 on: August 19, 2017, 04:39:04 am »
BeRo is an amazing programmer. And the structuring of his software is also very good !
You could use his SDL2 bindings and build your work upon them.
Later, you could easily switch over towards using Vulkan itself.
I use this one (with modify):
https://github.com/ev1313/Pascal-SDL-2-Headers
And, why vulkan need SDL?

There are also other alternatives:
Castle Game Engine : https://github.com/castle-engine
PXL: https://sourceforge.net/projects/asphyre/
Castle Game Engine is good, I had used once. But finally I fell it’s very OO and highly coupling. Too hard to modify. And some functions are not cross-platform consistent.
As for PXL, Asphyre has several generations of game engine, but none of them support audio. I even wondering PXL is inactive like ZenGL. = =

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1738
Re: BGRABitmap Thread Problem in Android
« Reply #9 on: August 19, 2017, 10:16:32 am »
I think I cannot help you any further unfortunately. Two reasons.

1.
Your SDL static lib for Android ARMV7 gives an error while linking:
Code: Pascal  [Select][+][-]
  1. libSDL2.a(SDL_android.o): In function `JNI_OnLoad':
  2. Debug: D:/develop/SDL2/SDL2-2.0.5/src/core/android/SDL_android.c:94: multiple definition of `JNI_OnLoad'
  3. project1\lib\android-arm-debug\project1.o:project1.lpr:(.text.n_JNI_OnLoad+0x0): first defined here
  4.  

2.
If I use a working SDL lib, the app dies on my phone without doing anything:
Quote
08-19 10:05:54.135  8989  8989 D SDL     : command: logcat -f /sdcard/app.log -v time *:V
08-19 10:05:54.155  8989  8989 V SDL     : Device: m0
08-19 10:05:54.155  8989  8989 V SDL     : Model: GT-I9300
08-19 10:05:54.155  8989  8989 V SDL     : onCreate(): null
08-19 10:05:54.155  8989  8989 D dalvikvm: Trying to load lib /data/app-lib/net.sourceforge.app-2/libapp.so 0x425f98a0
08-19 10:05:54.160  8989  8989 D dalvikvm: Added shared lib /data/app-lib/net.sourceforge.app-2/libapp.so 0x425f98a0
08-19 10:05:54.230  8989  8989 I SDL/APP : initialization Main
08-19 10:05:54.230  8989  8989 I SDL/APP : ====== application begin ======
08-19 10:05:54.715  1941  1941 D Zygote  : Process 8989 exited cleanly (211)
08-19 10:05:54.715  2349  2360 I ActivityManager: Process net.sourceforge.app (pid 8989) (adj 0) has died.
08-19 10:05:54.715  2349  2360 W ActivityManager: Force removing ActivityRecord{439b49f0 u0 net.sourceforge.app/org.libsdl.app.SDLActivity}: app died, no saved state

Sorry about this. I hope you will succeed in the end.

mercury

  • Full Member
  • ***
  • Posts: 154
Re: BGRABitmap Thread Problem in Android
« Reply #10 on: August 19, 2017, 02:16:40 pm »
I think I cannot help you any further unfortunately.
It’s ok. Thanks anyway.

 

TinyPortal © 2005-2018