首页 > 解决方案 > 调用 CompassService 在 iOS 上导致黑屏

问题描述

以下对 compassservice 的调用导致 iOS 上出现黑屏(充电图标可见)。这可能与最近的 iOS 12 更新有关?

Services.get(CompassService.class).ifPresent(consumer -> {

});

添加调用

public BasicView() {

    Label label = new Label("Hello JavaFX World!");

    Button button = new Button("Change the World!");
    button.setGraphic(new Icon(MaterialDesignIcon.LANGUAGE));
    button.setOnAction(e -> label.setText("Hello JavaFX Universe!"));

    VBox controls = new VBox(15.0, label, button);
    controls.setAlignment(Pos.CENTER);

    setCenter(controls);

    Services.get(CompassService.class).ifPresent(consumer -> {

    });
}

还会在新创建的项目中产生问题。

使用 1.3.15 插件和以下控制台输出时,我仍然会看到黑屏和电池电量:

Root pattern javax.annotations.**.* matches no classes
Root pattern javax.inject.**.* matches no classes
javax.xml.stream.XMLEventFactory=com.sun.xml.stream.events.ZephyrEvent...
java.vendor.url=http://www.robovm.org/
java.ext.dirs=
line.separator=

file.encoding=UTF-8
java.runtime.version=0.9
user.name=mobile
java.compiler=
prism.static.libraries=true
android.icu.unicode.version=6.2
javax.xml.stream.XMLOutputFactory=com.sun.xml.stream.ZephyrWriterFactory
java.version=0
android.icu.library.version=51.1.0.1
os.arch=aarch64
java.io.tmpdir=/private/var/mobile/Containers/Data/A...
glass.platform=ios
android.zlib.version=1.2.8
user.language=en
java.vm.version=2.3.5-SNAPSHOT
com.sun.javafx.isEmbedded=true
javax.xml.stream.XMLInputFactory=com.sun.xml.stream.ZephyrParserFactory
path.separator=:
java.runtime.name=RoboVM Runtime
java.specification.version=0.9
user.dir=/private/var/mobile/Containers/Data/A...
java.vm.specification.vendor=RoboVM
java.vm.name=RoboVM
java.vm.specification.version=0.9
prism.useNativeIIO=false
user.home=/private/var/mobile/Containers/Data/A...
jfxmedia.platforms=IOSPlatform
java.specification.name=RoboVM Core Library
file.separator=/
user.variant=
os.version=12.0
java.boot.class.path=/private/var/containers/Bundle/Applic...
java.vm.specification.name=RoboVM Virtual Machine Specification
javafx.platform=ios
user.region=SE
os.name=iOS
java.class.path=/private/var/containers/Bundle/Applic...
prism.verbose=true
java.specification.vendor=RoboVM
java.vm.vendor=RoboVM
prism.mintexturesize=16
prism.allowhidpi=true
java.vendor=RoboVM
android.icu.cldr.version=23.0
android.openssl.version=OpenSSL 1.0.1e 11 Feb 2013
java.home=/private/var/containers/Bundle/Applic...
java.vm.vendor.url=http://www.robovm.org/
java.class.version=50.0
Prism pipeline init order: es2 
Using native-based Pisces rasterizer
Using dirty region optimizations
Using system sized mask for primitives
Not forcing power of 2 sizes for textures
Using hardware CLAMP_TO_ZERO mode
Opting in for HiDPI pixel scaling
Prism pipeline name = com.sun.prism.es2.ES2Pipeline
Loading ES2 native library ... prism_es2
    succeeded.
GLFactory using com.sun.prism.es2.IOSGLFactory
IOSWindowSystemInterface : share 0 view 0 pf otready 
GL_VERSION string = OpenGL ES 2.0 Apple A8 GPU - 128.28.1
GL_VERSION (major.minor) = 0.0
  initialize() returns 4456491632
(X) Got class = class com.sun.prism.es2.ES2Pipeline
Initialized prism pipeline: com.sun.prism.es2.ES2Pipeline
IOSWindowSystemInterface : share 807dc360 view 0 pf otready 
GL_VERSION string = OpenGL ES 2.0 Apple A8 GPU - 128.28.1
GL_VERSION (major.minor) = 0.0
CTXINFO vendor
CTXINFO renderer
CTXINFO glExtensions
CTXINFO GL_ARB_pixel_buffer_object
CTXINFO allocate the structure
CTXINFO set function pointers
Attributes = onScreen: trueredSize : 8, greenSize : 8, blueSize : 8, alphaSize : 8, depthSize : 24, doubleBuffer : true
  initialize() returns 4454406448
IOSWindowSystemInterface : share 807dc360 view 0 pf otready 
GL_VERSION string = OpenGL ES 2.0 Apple A8 GPU - 128.28.1
GL_VERSION (major.minor) = 0.0
CTXINFO vendor
CTXINFO renderer
CTXINFO glExtensions
CTXINFO GL_ARB_pixel_buffer_object
CTXINFO allocate the structure
CTXINFO set function pointers
Attributes = onScreen: trueredSize : 8, greenSize : 8, blueSize : 8, alphaSize : 8, depthSize : 24, doubleBuffer : true
  initialize() returns 4456522224
Maximum supported texture size: 4096
Non power of two texture support = false
Maximum number of vertex attributes = 16
Maximum number of uniform vertex components = 512
Maximum number of uniform fragment components = 256
Maximum number of varying components = 32
Maximum number of texture units usable in a vertex shader = 8
Maximum number of texture units usable in a fragment shader = 8
Graphics Vendor: Apple Inc.
       Renderer: Apple A8 GPU
        Version: OpenGL ES 2.0 Apple A8 GPU - 128.28.1
 vsync: true vpipe: true
[WARN] java.lang.Class: Class.forName() failed to load 'com.sun.javafx.font.t2k.T2KFactory'. Use the -forcelinkclasses command line option or add <forceLinkClasses><pattern>com.sun.javafx.font.t2k.T2KFactory</pattern></forceLinkClasses> to your robovm.xml file to link it in.
2018-10-13 16:30:45.649938+0200 CompassApplicationApp[6651:1823208] Done creating private storage /var/mobile/Containers/Data/Application/897B119A-3C3E-4228-A28E-19E459DA8A16/Library/gluon
[WARN] java.lang.Class: Class.forName() failed to load 'com.sun.javafx.tk.quantum.QuantumMessagesBundle_en_SE'. Use the -forcelinkclasses command line option or add <forceLinkClasses><pattern>com.sun.javafx.tk.quantum.QuantumMessagesBundle_en_SE</pattern></forceLinkClasses> to your robovm.xml file to link it in.
[WARN] java.lang.Class: Class.forName() failed to load 'com.sun.javafx.tk.quantum.QuantumMessagesBundle_en'. Use the -forcelinkclasses command line option or add <forceLinkClasses><pattern>com.sun.javafx.tk.quantum.QuantumMessagesBundle_en</pattern></forceLinkClasses> to your robovm.xml file to link it in.
[WARN] java.lang.Class: Class.forName() failed to load 'com.sun.javafx.tk.quantum.QuantumMessagesBundle'. Use the -forcelinkclasses command line option or add <forceLinkClasses><pattern>com.sun.javafx.tk.quantum.QuantumMessagesBundle</pattern></forceLinkClasses> to your robovm.xml file to link it in.
[WARN] java.lang.Class: Class.forName() failed to load 'com.oracle.jrockit.jfr.FlightRecorder'. Use the -forcelinkclasses command line option or add <forceLinkClasses><pattern>com.oracle.jrockit.jfr.FlightRecorder</pattern></forceLinkClasses> to your robovm.xml file to link it in.
2018-10-13 16:30:58.392847+0200 CompassApplicationApp[6651:1823245] XPC connection interrupted

构建脚本如下:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.3.15'
    }
}

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'com.gluonapplication.CompassApplication'

dependencies {
    compile 'com.gluonhq:charm:5.0.0'
}

jfxmobile {
    downConfig {
        version = '3.8.4'
        // Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
        plugins 'compass', 'display', 'lifecycle', 'magnetometer', 'statusbar', 'storage'
    }
    android {
        manifest = 'src/android/AndroidManifest.xml'
    }
    ios {
        // javafxportsVersion="8.60.11"
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.gluonhq.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}

运行 jdk1.8.0_181 我还可以提到关闭并重新启动应用程序时屏幕是全白的。

标签: gluongluon-mobile

解决方案


推荐阅读