[FIXED] OSX / Java 7

Started by normen, August 14, 2012, 17:07:59

Previous topic - Next topic

Grum

kappa, I think I might know what causes the duplicate window to happen.

I installed gfxCardStatus that allows me to switch between Integrated/Discrete video accelerators. It also notifies me when the system changes the settings. I noticed that I occasionally still got a duplicated window (as it it was not parented) during development and that in those cases the 'switch' was 'early'. So maybe somehow the swapping from intel <-> nvidia causes something to lock up and an extra window to spawn?

Or maybe the window gets recreated and somehow lost thus it cannot be parented?

Ixmal

@kappa

Whether we want it or not, Apple wants developers to use CoreAnimation layers. Right now it's the only option for Safari plugins, but in future I would expect layers to be forced for desktop apps as well. Just because it makes OS X life much easier by controlling what, when, and where is rendered by applications.

AWT team at Oracle is about to provide a Java class, that is a wrapper over real NSView. Most likely, this NSView will be backed by CALayer, but it's too early to say it for sure right now. Is LWGJL team interested in this at all?

Grum

Crash i had just now:

2012-12-01 13:29:25.940 java[16337:707] *** -[NSArray initWithArray:range:copyItems:]: range {0, 4} extends beyond bounds [0 .. 2]
2012-12-01 13:29:25.942 java[16337:707] (
	0   CoreFoundation                      0x00007fff88d570a6 __exceptionPreprocess + 198
	1   libobjc.A.dylib                     0x00007fff8518f3f0 objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff88d0c0e4 -[NSArray initWithArray:range:copyItems:] + 212
	3   AppKit                              0x00007fff89279079 -[NSView(NSInternal) _updateTrackingAreas] + 1201
	4   AppKit                              0x00007fff89278aac _handleInvalidCursorRectsNote + 863
	5   AppKit                              0x00007fff89776551 __35-[NSWindow _postInvalidCursorRects]_block_invoke_02794 + 46
	6   CoreFoundation                      0x00007fff88d1d9b7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
	7   CoreFoundation                      0x00007fff88d1d921 __CFRunLoopDoObservers + 369
	8   CoreFoundation                      0x00007fff88cf8d88 __CFRunLoopRun + 728
	9   CoreFoundation                      0x00007fff88cf86b2 CFRunLoopRunSpecific + 290
	10  HIToolbox                           0x00007fff8e9510a4 RunCurrentEventLoopInMode + 209
	11  HIToolbox                           0x00007fff8e950e42 ReceiveNextEventCommon + 356
	12  HIToolbox                           0x00007fff8e950cd3 BlockUntilNextEventMatchingListInMode + 62
	13  AppKit                              0x00007fff8919e613 _DPSNextEvent + 685
	14  AppKit                              0x00007fff8919ded2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
	15  libawt.jnilib                       0x0000000117200fdb -[NSApplicationAWT nextEventMatchingMask:untilDate:inMode:dequeue:] + 124
	16  AppKit                              0x00007fff89195283 -[NSApplication run] + 517
	17  libawt.jnilib                       0x00000001171ff68c +[AWTStarter startAWT:] + 1495
	18  libawt.jnilib                       0x00000001171ff006 -[CPerformer perform] + 93
	19  Foundation                          0x00007fff8b614677 __NSThreadPerformPerform + 225
	20  CoreFoundation                      0x00007fff88cd6101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	21  CoreFoundation                      0x00007fff88cd5a25 __CFRunLoopDoSources0 + 245
	22  CoreFoundation                      0x00007fff88cf8dc5 __CFRunLoopRun + 789
	23  CoreFoundation                      0x00007fff88cf86b2 CFRunLoopRunSpecific + 290
	24  java                                0x000000010b992843 java + 18499
	25  java                                0x000000010b99229a java + 17050
	26  java                                0x000000010b98fa98 java + 6808
)


It followed after restarting Minecraft (debugger attached) after it spawned the 'double windows'.

kappa

New update:

- total re-implementation of fullscreen mode, should work pretty nice now.
- resizing fixed, should work as expected now (including when switching to and from fullscreen).
- scroll wheel implemented.
- fixed a few native crash issues.
- fixes for keyboard keys that didn't work (credit to Grum).
- some code clean up.

Latest experimental build here: https://www.dropbox.com/s/b6gj27dmoyo0h0j/macosx.zip

Tested 'Revenge of the Titans' using the above build, game works pretty flawlessly for me now.

@adamk33n3r - your fullscreen issue should be fixed now.

@Ixmal - thanks for dropping by, having access to a real NSView would be nice but I do understand the reasons it would need to be backed by a CALayer (maybe have an option to allow non CALayer NSViews too, where possible? that would be useful to LWJGL for fast rendering in AWT applications). As I understand it (after a bit of googling), rendering OpenGL to NSViews backed by a layer doesn't work too well. Seems mainly like a limitation of how Core Animation works when trying to render to it using another thread. For CALayers, using the slower render to texture and then draw to a CALayer seems like the most feasible way for LWJGL to go atm for AWT support.

princec

Nice work kappa!

... now, what's the score with deploying OpenJDK7 apps on Mac OS using embedded VMs?

Cas :)

adamk33n3r

Quote from: kappa on December 09, 2012, 18:12:05
New update:

- total re-implementation of fullscreen mode, should work pretty nice now.
- resizing fixed, should work as expected now (including when switching to and from fullscreen).
- scroll wheel implemented.
- fixed a few native crash issues.
- fixes for keyboard keys that didn't work (credit to Grum).
- some code clean up.

Latest experimental build here: https://www.dropbox.com/s/b6gj27dmoyo0h0j/macosx.zip

Tested 'Revenge of the Titans' using the above build, game works pretty flawlessly for me now.

@adamk33n3r - your fullscreen issue should be fixed now.

@Ixmal - thanks for dropping by, having access to a real NSView would be nice but I do understand the reasons it would need to be backed by a CALayer (maybe have an option for non CALayer NSViews too? that would be useful to LWJGL for fast rendering in AWT applications). As I understand it (after a bit of googling), rendering OpenGL to NSViews backed by a layer doesn't work too well. Seems mainly like a limitation of how Core Animation works when trying to render to it using another thread. Using the slower render to texture and then draw to a CALayer seems like the most feasible way for LWJGL to go atm for AWT support.

@kappa Thanks it works great now! Just something to tell you though: I'm getting a "invalid drawable" most of the time when I go fullscreen. It doesn't seem to be doing anything wrong but it's an error so I thought I'd let you know. Again, thanks

Komoden

Just tested with latest Minecraft.

The scroll direction is inverted, don't know if this is an implementation problem in LWJGL or in Minecraft.

When using the launcher it seems happy to work, when attempting to start from terminal i get this:
QuoteException in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException
   at java.lang.Class.getDeclaredMethods0(Native Method)
   at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
   at java.lang.Class.getMethod0(Class.java:2685)
   at java.lang.Class.getMethod(Class.java:1620)
   at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:492)
   at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:484)
Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException
   at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
   ... 6 more

Tried starting it with a third party program and it gets stuck when loading LWJGL under Java 7, but works just fine with Java 6 (couldn't get any logs from the "stuck" state, it just stops responding entirely)

Am also getting crash reports when closing the game. Can post these if necessary

kappa

@Komoden good to know that it still works with launcher. Something is wrong with your settings when using the terminal, ensure lwjgl.jar is included in the classpath.

Not focused much on getting the Display.setParent()/AWTGLCanvas stuff working correctly yet as it needs a big rewrite and will be the most tricky part to get right. Currently focused on getting the pure native Display functionality fully working first. Anyway, was aware of the crash on close when using Display.setParent(), will look into getting that sorted soon.

I'll double check the scroll wheel direction, might have it the wrong way round.

@adamk33n3r - the "invalid drawable" should be harmless message for now, but will get that fixed.

Anyway thanks for testing ppl.

pizza2004

I tried it out and you definitely got scroll in there backwards.  Other than that the only errors I see are that Minecraft crashes when I tell it to close, and it puts the version text in the title bar of the window in addition to the Minecraft text that's normally there.

I had the same error Komoden had when I tried to start Minecraft with the launcher jar by double clicking instead of putting in the necessary arguments the launcher normally does.  When I added at the very least the two arguments to set the amount of RAM it worked perfectly fine and ran with Java 7.

kappa

New update:

- implemented Mouse.setCursorPosition().
- implemented Display.getX() and Display.getY().
- implemented Display.isActive().
- fixed 'invalid drawable' error - as reported by @adamk33n3r.
- corrected scroll wheel direction - as reported by @Komoden and @pizza2004.
- fixed crash on exit when using Display.setParent().
- some more code clean up.

Latest experimental build here: https://www.dropbox.com/s/b6gj27dmoyo0h0j/macosx.zip

Two things remain now after which the code is ready to be merged into LWJGL's main branch:

1) Implement native cursor support (shouldn't be too difficult).
2) Re-implement the AWT/Display.setParent support to use FBO's internally with the JAWT CALayer API (will allow LWJGL applications that use AWT to run on Java 7 and as Java Applet).

Matzon

excellent work! keep 'em coming :)

pizza2004

Thanks, this definitely fixes the scrolling and the crash on close bugs.  However I'm still seeing this bug:

Before when you ran Minecraft it would say "Minecraft" in the title bar of the window.  Now, with this current version of LWJGL it displays "Minecraft Minecraft 1.4.6" in the title bar.  Any ideas why this is happening?  Should this be happening?

I also am now unable to run Minecraft using Java 7 at all.  It gets stuck at the LWJGL loading stage, but I can't imagine why I'd have to include the class path name for LWJGL in the terminal command as I'm running the Minecraft Launcher with Java 7.

kurakin

I guess I picked a bad time to start playing with OpenGL and Java, because I mainly develop on a MacbookPro and I'm running Java7. That said, I can get the intro tutorials on the lwjgl doc page to work fine, but the 3.2+ ones I can't get to work at all. The drawArrays one gives me "Invalid Operation" in the loop cycle and the drawElements on doesn't draw the quad at all, just the bluish background. Is there something I'm missing that should be in those tutorials? I know about the ContextAttribs being an immutable object and the calls should be chained, and I've tried taking out the glViewport calls, but it doesn't appear to have an effect.

bobbo

I am eagerly anticipating further developments on this issue. I am testing with the current experimental build, please keep the updates coming!
Thank you, kappa.

kappa

Quote from: bobbo on December 25, 2012, 22:12:44
I am eagerly anticipating further developments on this issue. I am testing with the current experimental build, please keep the updates coming!
Thank you, kappa.
progress is being made, slowly but surely, currently trying to get the Display.setParent/AWT stuff working using the JAWT/CALayer API, this should allow Display.setParent() to work correctly on Java 7 and with Java applets. Will post the next update as soon as its in a usable form.