MegaMek / megameklab

MegaMekLab is a BattleTech unit modification program. It allows creating and modifying all unit types available in MegaMek from Support Vehicles up to WarShips. It also allows printing record sheets for single or multiple units.
http://www.megamek.org
86 stars 132 forks source link

Several Issue with the Mac Version #23

Closed LeftoverNoodles closed 8 years ago

LeftoverNoodles commented 8 years ago

MLL is not working well on my Mac. I have a with the Java6SE and the JRE8 installed. The few times things have outright crashed it's been while running Java8.

Here is a quick rundown

Launching the App with the Open -n command

LSOpenURLsWithRole() failed with error -10810 for the file /Users/Geg/Documents/Battletech/MegaMek/megameklab-0.1.57-mac/MegaMekLab.app.

When trying to load the Jar with Java6:

Exception in thread "main" java.lang.UnsupportedClassVersionError: megameklab/com/MegaMekLab : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Friday:Commands Geg$

When Trying to Load the raw Jar from the command line (JRE8):

Unable to redirect output Memory Allocated [3817865] java.io.FileNotFoundException: ./data/fonts/Eurosti.TTF (No such file or directory) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.(FileInputStream.java:138) at megameklab.com.util.UnitUtil.loadFonts(UnitUtil.java:1640) at megameklab.com.ui.MegaMekLabMainUI.(MegaMekLabMainUI.java:50) at megameklab.com.ui.Mek.MainUI.(MainUI.java:65) at megameklab.com.MegaMekLab.main(MegaMekLab.java:139) ./data/fonts/Eurosti.TTF not loaded. Using Arial font. java.io.FileNotFoundException: ./data/fonts/Eurostib.TTF (No such file or directory) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.(FileInputStream.java:138) at megameklab.com.util.UnitUtil.loadFonts(UnitUtil.java:1652) at megameklab.com.ui.MegaMekLabMainUI.(MegaMekLabMainUI.java:50) at megameklab.com.ui.Mek.MainUI.(MainUI.java:65) at megameklab.com.MegaMekLab.main(MegaMekLab.java:139) ./data/fonts/Eurostib.TTF not loaded. Using Arial font.

HammerGS commented 8 years ago

Not a Mac Expert but you might want to stuff from here: http://megamek.info/forums/index.php?topic=2383.0 Also looks like its missing a font - Eurosti.TTF which should be included in the release.

I know some people have said they have had more luck running the Linux version: https://github.com/MegaMek/megameklab/releases/download/v0.1.58/megameklab-0.1.58.tar.gz

One of the Mac savy dev's should be around at some point.

LeftoverNoodles commented 8 years ago

Thanks. The Linux Version works better. The Font was included and at the location where the application was looking. However, when I try to print (printer and file) with the Linux version. I still crash:

Process: java [2290] Path: /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/bin/java Identifier: net.java.openjdk.cmd Version: 1.0 (1.0) Code Type: X86-64 (Native) Parent Process: Jar Launcher [2289] Responsible: java [2290] User ID: 501

Date/Time: 2016-08-27 12:10:10.210 -0400 OS Version: Mac OS X 10.11.6 (15G31) Report Version: 11 Anonymous UUID: D670390A-4DAA-808D-66CD-54F88300A1A6

Time Awake Since Boot: 6900 seconds

System Integrity Protection: disabled

Crashed Thread: 26 Java: AWT-EventQueue-0

Exception Type: EXC_BAD_ACCESS (SIGABRT) Exception Codes: KERN_PROTECTION_FAILURE at 0x00000001022ff100 Exception Note: EXC_CORPSE_NOTIFY

VM Regions Near 0x1022ff100: __LINKEDIT 00000001022f1000-00000001022ff000 [ 56K] r--/rwx SM=COW /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre/lib/libjava.dylib --> VM_ALLOCATE 00000001022ff000-0000000102300000 [ 4K] r--/rwx SM=PRV
shared memory 0000000102300000-0000000102301000 [ 4K] r--/rw- SM=SHM

Application Specific Information: *\ Terminating app due to uncaught exception 'JavaNativeException', reason: 'java.lang.NoSuchFieldError: sData' terminating with uncaught exception of type JNFException abort() called

HammerGS commented 8 years ago

I'm not going be able to help with that one. But I'm sure @Dylan-M @arlith might have some ideas.

arlith commented 8 years ago

All of the programs are built with Java 1.7, so your Java6SE isn't going to work. That's basically what this error is telling you: Exception in thread "main" java.lang.UnsupportedClassVersionError: megameklab/com/MegaMekLab : Unsupported major.minor version 51.0 That's happening because you're trying to run something compiled in a later version of Java.

I'll have to get back to you on the other error.

LeftoverNoodles commented 8 years ago

Good to know. The only reason I installed Java6SE is because OSX recommended it to me to run MML has legacy content.

I installed Java 1.7. Largely getting the same behavior. OSX App won't open, hangs on loading from cache when launched via the jar. The Linux Jar seams to work fine. Neither can print to the printer or to a file.

Warning from the Mac Jar Log File Memory Allocated [3817865] Starting MegaMekLab version: 0.1.57 MMRandom: generating RNG type #1 WARN: Could not load custom weapon orders from customWeaponOrder.xml Exception in thread "Mech Cache Loader" java.lang.NoClassDefFoundError: com/thoughtworks/xstream/converters/Converter

When trying to print via Linux Version of Java /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

Crash Dump Process: java [684] Path: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java Identifier: net.java.openjdk.cmd Version: 1.0 (1.0) Code Type: X86-64 (Native) Parent Process: Jar Launcher [683] Responsible: java [684] User ID: 501

Date/Time: 2016-08-27 15:20:20.613 -0400 OS Version: Mac OS X 10.11.6 (15G31) Report Version: 11 Anonymous UUID: D670390A-4DAA-808D-66CD-54F88300A1A6

Time Awake Since Boot: 340 seconds

System Integrity Protection: disabled

Crashed Thread: 27 Java: AWT-EventQueue-0

Exception Type: EXC_BAD_ACCESS (SIGABRT) Exception Codes: KERN_INVALID_ADDRESS at 0x000000000000000c Exception Note: EXC_CORPSE_NOTIFY

VM Regions Near 0xc: --> __TEXT 0000000101cee000-0000000101cff000 [ 68K] r-x/rwx SM=COW /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java

Application Specific Information: *\ Terminating app due to uncaught exception 'JavaNativeException', reason: 'java.lang.NoSuchFieldError: sData' terminating with uncaught exception of type JNFException abort() called

Dylan-M commented 8 years ago

@LeftoverNoodles The Java you download from java.com won't work properly, it's the browser plugin (As your manual path clearly shows). On OSX, for everything to work correctly you need to install the JDK. I recommend doing it via homebrew, but if you're not willing to use brew follow these steps:

  1. Remove all installed Java on your machine
  2. Install JDK 8 from this link: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
  3. Try to run the program again.

I'm having you get JDK8 because the next stable will actually be released using Java 8 rather than Java 7.

If you're a homebrew user (Or willing to become one, I recommend it!), follow these steps instead:

  1. Remove all existing Java from your system
  2. Run the following brew commands: brew update brew upgrade brew cask install java (The brew command should be close, but I'm doing it from memory so it might be a little bit different)
LeftoverNoodles commented 8 years ago

I've installed the Java 8 JDK from Oracle and removed all other versions of Java from the computer. I am not a homebrew user. It looks like a package management tool similar to apt from back in the day. It sounds like it might duplicate the effort of the Java install from oracle.

java -version java version "1.8.0_102" Java(TM) SE Runtime Environment (build 1.8.0_102-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)

I am getting the same general behaviors from both the linux and the mac versions of the software.

Running the .App gives this error: http://imgur.com/a/1zszV

Running the Mac .jar mostly works. It hangs when loading the cache, and doesn't do anything when you attempt to print. Running the Linux jar works better, but still crashed when trying to print.

The log file from the mac.jar look like this:

Memory Allocated [3817865] Starting MegaMekLab version: 0.1.57 MMRandom: generating RNG type #1 WARN: Could not load custom weapon orders from customWeaponOrder.xml Exception in thread "Mech Cache Loader" java.lang.NoClassDefFoundError: com/thoughtworks/xstream/converters/Converter at megamek.common.EquipmentType.getGameOptions(EquipmentType.java:1005) at megamek.common.weapons.ACWeapon.getDamage(ACWeapon.java:107) at megamek.common.Entity.hasViableWeapons(Entity.java:845) at megamek.common.Entity.initMilitary(Entity.java:833) at megamek.common.MechFileParser.postLoadInit(MechFileParser.java:895) at megamek.common.MechFileParser.parse(MechFileParser.java:205) at megamek.common.MechFileParser.(MechFileParser.java:118) at megamek.common.MechSummaryCache.loadMechsFromZipFile(MechSummaryCache.java:648) at megamek.common.MechSummaryCache.loadMechsFromDirectory(MechSummaryCache.java:548) at megamek.common.MechSummaryCache.loadMechData(MechSummaryCache.java:245) at megamek.common.MechSummaryCache$1.run(MechSummaryCache.java:94) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassNotFoundException: com.thoughtworks.xstream.converters.Converter at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

wildj79 commented 8 years ago

I can confirm getting an error while trying to print from linux version 0.1.57. See attached error log. error.txt.

OS: Mac OS X 10.11.6

java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
wildj79 commented 8 years ago

Same issue on 0.1.58 error.txt

arlith commented 8 years ago

This looks like a Java compatibility issue to me. This is the relevant stack trace:

2016-08-28 00:43:05.418 java[926:134758] An uncaught exception was raised
2016-08-28 00:43:05.419 java[926:134758] java.lang.NoSuchFieldError: sData
    at sun.java2d.OSXOffScreenSurfaceData.getSurfaceData(Native Method)
    at sun.java2d.OSXOffScreenSurfaceData.getCopyWithBgColor(OSXOffScreenSurfaceData.java:585)
    at sun.java2d.OSXSurfaceData.blitImage(OSXSurfaceData.java:1024)
    at sun.java2d.CRenderer.blitImage(CRenderer.java:461)
    at sun.java2d.CRenderer.scaleImage(CRenderer.java:455)
    at sun.java2d.CRenderer.scaleImage(CRenderer.java:401)
    at sun.java2d.CRenderer.scaleImage(CRenderer.java:557)
    at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3274)
    at sun.awt.image.ImageRepresentation.drawToBufImage(ImageRepresentation.java:845)
    at sun.java2d.CRenderer.scaleImage(CRenderer.java:562)
    at sun.java2d.pipe.ValidatePipe.scaleImage(ValidatePipe.java:207)
    at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3274)
    at sun.lwawt.macosx.CPrinterGraphics.drawImage(CPrinterGraphics.java:62)
    at megameklab.com.ui.Mek.Printing.PrintMech.printMekImage(PrintMech.java:889)
    at megameklab.com.ui.Mek.Printing.PrintMech.printImage(PrintMech.java:109)
    at megameklab.com.ui.Mek.Printing.PrintMech.print(PrintMech.java:93)
        ...
arlith commented 8 years ago

I found someone else having this issue with a different project: http://www.dbschema.com/forum/viewtopic.php?t=471. The suggestion was to reinstall Java; not very reassuring.

LeftoverNoodles commented 8 years ago

I was successfully able to print to both file and printer from SSW (the only other jar program I have on hand) with Java 1.8.0_102. I did want to confirm that Java itself was still working.

Dylan-M commented 8 years ago

I'm also not sure why this isn't working. I've never tried to print from my OSX machine. I'll see if I have time to do so on Monday. Sadly, I've not tested MML much under OSX, just MM and MHQ.

wildj79 commented 8 years ago

Just for completeness, I decided to test printing a Quad design, just to see if it would have the same issue. It didn't. The quad design printed just fine. So I opened up the PrintQuad.java and PrintMech.java files to see what was different. This is what I found:

PrintMech.java:883


private void printMekImage(Graphics2D g2d, Image img) {

        int width = Math.min(148, img.getWidth(null));
        int height = Math.min(200, img.getHeight(null));
        int drawingX = 237 + ((148 - width) / 2);
        int drawingY = 172 + ((200 - height) / 2);
        g2d.drawImage(img, drawingX + leftMargin, topMargin + drawingY, width, height, Color.BLACK, null);

    }

PrintQuad.java:1456


private void printMekImage(Graphics2D g2d, Image img) {

        int width = Math.min(148, img.getWidth(null));
        int height = Math.min(200, img.getHeight(null));
        g2d.drawImage(img, 237 + leftMargin, 172 + topMargin, width, height, null);

        // g2d.drawRect(235, 172, 165, 200);
    }

If you make the printMekImage(Graphics2D g2d, Image img) method of PrintMech.java the same as the method of PrintQuad.java and recompile, the issue goes away.

mhjacks commented 8 years ago

+1 for a release with this issue fixed.

arlith commented 8 years ago

@wildj79 Thanks for the PR. When I saw Bee's comment I had thought something similar would fix the problem.

@mhjacks You can add reactions to comments. I'm not sure that it would have the same effect, as I don't think anyone gets emails, but it also doesn't create a new post. Unfortunately, since we just had a new release, there likely won't be another release for a few weeks.

wildj79 commented 8 years ago

I've been looking into the main issue that @LeftoverNoodles had created. From what I've been able to find on google, the method being used to create the Mac application bundle has been deprecated for quite some time. The developer documentation on the Apple developer site that details how to create a Java based application bundle is way out of date. Finding current documentation is next to impossible. I did manage to find a couple of blog posts and tutorials. I'm working on updating the project to hopefully produce a usable Mac app bundle.

Dylan-M commented 8 years ago

@wildj79 Actually, the method we're using just looks like an old outdated method. It's actually a script that replicates the old method, but is actually far more advanced. I'm honestly not sure why anyone is having issues. Everything works just fine for me on both Lion and El Capitan, which should mean it works fine on everything in between.

Most of the issues are simply people not installing Java correctly. When you visit www.java.com from a Mac, the download it automatically offers up is just a browser plugin version of the JRE. If one wants the full JRE they need to remove every version of Java from their Mac and then install the latest JDK. This is easiest done if they just use Homebrew to install Java rather than trying to do it manually.

However, none of this is obvious to Mac users, and they're so used to Apple just giving them everything that they don't know better. It's one of the reasons I seriously dislike Apple. But, it brings me back to: There is nothing wrong with our packaging. The software works just fine on everything I've tested, which doesn't yet include Sierra or whatever the latest one is.

And... of course, I went to take a screenshot, only to learn that MML only is broken. Which means it's a packaging issue, not an issue with the our method. This is fixable ;) MegaMek and MekHQ both work correctly, as demonstrated by the below only erroring for MML: djs-macbook:mekhq-0.3.27-dylan-mac dylanmyers$ open -a MegaMekLab.app The application /Users/dylanmyers/git/megameklab/packaging_utils/MegaMekLab.app cannot be opened because its executable is missing. djs-macbook:mekhq-0.3.27-dylan-mac dylanmyers$ open -a MekHQ.app djs-macbook:mekhq-0.3.27-dylan-mac dylanmyers$ open -a MegaMek.app djs-macbook:mekhq-0.3.27-dylan-mac dylanmyers$

Dylan-M commented 8 years ago

For those in this thread having issues, please give the following release a try: https://github.com/MegaMek/megameklab/releases/tag/OSX_Packaging_Test

LeftoverNoodles commented 8 years ago

I've cleaver updated to macOS Sierra now.

Dylan-M commented 8 years ago

Okay, I'm going to solve this by doing a complete re-write of the OSX packaging to make proper use of the new changes that have come out to universalJavaApplicationStub and the compatibility it has with AppBundler.