From 167d21ec46203b1d44208b864f8ac04b8cd57e92 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sat, 5 May 2018 03:15:17 +0900 Subject: [PATCH] devicescale: Panic on Android when called from init funcs --- internal/devicescale/impl_android.go | 2 +- run.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/devicescale/impl_android.go b/internal/devicescale/impl_android.go index 15d6954c2..3db01425c 100644 --- a/internal/devicescale/impl_android.go +++ b/internal/devicescale/impl_android.go @@ -65,7 +65,7 @@ import ( func impl() float64 { if !jni.IsJVMAvailable() { - return 0 + panic("devicescale: JVM is not available yet: is this called from init funcitons?") } s := 0.0 if err := jni.RunOnJVM(func(vm, env, ctx uintptr) error { diff --git a/run.go b/run.go index 8e988e3b2..fff07362e 100644 --- a/run.go +++ b/run.go @@ -502,8 +502,7 @@ func SetWindowIcon(iconImages []image.Image) { // DeviceScaleFactor returns a meaningful value on high-DPI display environment, // otherwise DeviceScaleFactor returns 1. // -// DeviceScaleFactor might return 0 on init function on some devices like Android. -// Don't expect DeviceScaleFactor returns a valid value until main starts. +// DeviceScaleFactor might panic on init function on some devices like Android. // Then, it is not recommended to call DeviceScaleFactor from init functions. // // DeviceScaleFactor is concurrent-safe.