Bug 853 - Android w/ Intel [Atom] CPU failure when gluegen Platform inits
Summary: Android w/ Intel [Atom] CPU failure when gluegen Platform inits
Status: RESOLVED FIXED
Alias: None
Product: Gluegen
Classification: JogAmp
Component: core (show other bugs)
Version: 2
Hardware: embedded_arm other
: P3 enhancement
Assignee: Sven Gothel
URL:
Depends on: 856
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-10 11:52 CEST by Brice Figureau
Modified: 2014-01-24 13:08 CET (History)
1 user (show)

See Also:
Type: ---
SCM Refs:
Workaround: ---


Attachments
Galaxy Tab 3 10.1 hardware informations (12.33 KB, text/plain)
2013-10-10 11:52 CEST, Brice Figureau
Details
Galaxy Tab 3 10.1 cpuinfo (3.44 KB, text/plain)
2013-10-10 12:57 CEST, Brice Figureau
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brice Figureau 2013-10-10 11:52:14 CEST
Created attachment 513 [details]
Galaxy Tab 3 10.1 hardware informations

The Samsung Galaxy Tab 3 10.1 runs Android 4.2.2 on an Intel Atom Z2560 with an x86 instruction set *and* support for ARMv7 (I don't really know if that's an emulation or something else, we have native armv7 code running on the beast).

When we init a GLProfile, gluegen loads and Platform inits. The Platform codes detects the x86 part of the hardware and fails with this exception:

10-10 12:47:34.097: E/AndroidRuntime(26628): FATAL EXCEPTION: main
10-10 12:47:34.097: E/AndroidRuntime(26628): java.lang.ExceptionInInitializerError
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at com.daysofwonder.tt.android.TTActivity.getGLProfile(TTActivity.java:434)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at com.daysofwonder.tt.android.TTActivity.onCreate(TTActivity.java:181)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at android.app.Activity.performCreate(Activity.java:5267)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at android.app.ActivityThread.access$700(ActivityThread.java:150)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at android.os.Handler.dispatchMessage(Handler.java:99)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at android.os.Looper.loop(Looper.java:176)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at android.app.ActivityThread.main(ActivityThread.java:5279)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at java.lang.reflect.Method.invokeNative(Native Method)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at java.lang.reflect.Method.invoke(Method.java:511)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at dalvik.system.NativeStart.main(Native Method)
10-10 12:47:34.097: E/AndroidRuntime(26628): Caused by: java.lang.ExceptionInInitializerError
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:82)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	... 16 more
10-10 12:47:34.097: E/AndroidRuntime(26628): Caused by: java.lang.RuntimeException: Incompatible MachineDescriptions:
10-10 12:47:34.097: E/AndroidRuntime(26628):  Static MachineDescriptionStatic: X86_32_UNIX(1): MachineDescription: runtimeValidated false, littleEndian true, 32Bit true, primitive size / alignment:
10-10 12:47:34.097: E/AndroidRuntime(26628):   int8    1 / 1, int16   2 / 2
10-10 12:47:34.097: E/AndroidRuntime(26628):   int     4 / 4, long    4 / 4
10-10 12:47:34.097: E/AndroidRuntime(26628):   int32   4 / 4, int64   8 / 4
10-10 12:47:34.097: E/AndroidRuntime(26628):   float   4 / 4, double  8 / 4, ldouble 12 / 4
10-10 12:47:34.097: E/AndroidRuntime(26628):   pointer 4 / 4, page    4096
10-10 12:47:34.097: E/AndroidRuntime(26628):  Runtime MachineDescription: runtimeValidated true, littleEndian true, 32Bit true, primitive size / alignment:
10-10 12:47:34.097: E/AndroidRuntime(26628):   int8    1 / 1, int16   2 / 2
10-10 12:47:34.097: E/AndroidRuntime(26628):   int     4 / 4, long    4 / 4
10-10 12:47:34.097: E/AndroidRuntime(26628):   int32   4 / 4, int64   8 / 8
10-10 12:47:34.097: E/AndroidRuntime(26628):   float   4 / 4, double  8 / 8, ldouble 8 / 8
10-10 12:47:34.097: E/AndroidRuntime(26628):   pointer 4 / 4, page    4096
10-10 12:47:34.097: E/AndroidRuntime(26628): 	at com.jogamp.common.os.Platform.<clinit>(Platform.java:237)
10-10 12:47:34.097: E/AndroidRuntime(26628): 	... 17 more

which well is kind of normal since there is no Android x86 builds of gluegen/jogl/joal.

But there's no reason it can't detect the ARM instruction set and run with it, since it is fully supported by the hardware.
Gluegen detects the current architecture by parsing the dalvik system property "os.arch" which in our case returns "686".

It would be advisable to use the android.os.Build information to check for all defined ABI.

On this galaxy tab 3 10.1, this gives:
android.os.Build.CPU_ABI: x86
android.os.Build.CPU_ABI2: armeabi-v7a

Thus this would allow to detect that the device runs both arch natively.
Comment 1 Brice Figureau 2013-10-10 12:57:25 CEST
Created attachment 514 [details]
Galaxy Tab 3 10.1 cpuinfo
Comment 2 Sven Gothel 2013-10-10 14:51:11 CEST
(In reply to comment #1)
> Created attachment 514 [details]
> Galaxy Tab 3 10.1 cpuinfo

Yes, we trigger on 'os.arch' as a starting point to identify the 'MachineDescription'.
This aligns w/ 'android.os.Build.CPU_ABI: x86'

Ofc we shall support native x86 32bit/64bit if possible where available 
_and_ supported on Android.

+++

We may also add support for Androids dual ABI capability, 
i.e. your 'android.os.Build.CPU_ABI2: armeabi-v7a'

+++

This will result in actually 2 tasks.
Comment 3 Sven Gothel 2013-10-10 21:28:12 CEST
Same CPU config: ASUS MeMO Pad FHD 10 ?
Comment 4 Sven Gothel 2013-10-18 22:28:10 CEST
Moved this and Bug 855 to "P3 . enhancements", since it is no regression but a new feature.

Bug 856 tackles the emulation part and is of even lower priority.

Still waiting for devices .. will support Android Intel eventually depending on priorities.
Comment 5 Brice Figureau 2013-10-29 10:30:34 CET
We worked around the issue by using the ARM emulation on this device by doing this prior to gluegen initialization:

In our main activity:

>	static {
>		if (!Build.CPU_ABI.contains("armeabi")) {
>			log.info("Detected an non ARM primary arch {} / secondary: {}", Build.CPU_ABI, Build.CPU_ABI2);
>			String compatArch = System.getProperty("os.arch");
>			if ("armeabi-v7a".equalsIgnoreCase(Build.CPU_ABI2)) {
>				compatArch = "armv7l";
>			} else if ("armeabi".equalsIgnoreCase(Build.CPU_ABI2)) {
>    			compatArch = "armv6l";
			}
			log.info("Injecting os.arch {}", compatArch);
			System.setProperty("os.arch", compatArch);
		}
	}
Comment 6 Sven Gothel 2014-01-24 13:08:31 CET
Fixed .. due to fix of Bug 856