Textfield focus issue on javafxports 8.60.7 - javafxports

After switching to javafxports version 8.60.7 I encounter some strange bevahiour on TextField.
When I tap on a textfield the keyboard shows up, but the textfield doesn't get focused and I am not able to input any character. When I switch the keyboard type (from SwiftKey to Google or vice versa) it works, but only on the selected textfield. I am still not able to focus any other textField.
Furthermore after selecting a textField, the view seems to freeze. I can not navigate back, or show dialogs, though logcat shows the according touchevents and the methods of the view presenter class are called as normal.
Another view that contains a textfield can't be reached from the mainView any longer. When I press the button that triggers the switching to the view, the keyboard shows up above the mainView, and the view freezes again (I included the according logcat output at the end).
On javafxports 8.60.6 everything worked fine.
I'm running javafxports on a Huawei Y-300, with Android 4.1.1
/src/android/resources/java.custom.properties:
monocle.platform=Android
monocle.stackSize=128000
build.gradle:
buildscript {
repositories {
jcenter()
maven {
url 'http://dl.bintray.com/cjstehno/public'
}
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.7'
classpath 'gradle-templates:gradle-templates:1.4.1'
classpath "com.smokejumperit.gradle.license:Gradle-License-Report:0.0.2"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.12.0'
}
}
plugins {
id "org.sonarqube" version "1.1"
}
apply plugin: 'org.javafxports.jfxmobile'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.sonarqube'
apply plugin: 'project-reports'
apply plugin: 'license-report'
apply plugin: 'com.github.ben-manes.versions'
mainClassName = 'com.energymeter.EnergyMeterApp'
jfxmobile {
javafxportsVersion = '8.60.7'
android {
androidSdk = 'F:/AndroidSDK'
manifest = 'src/android/AndroidManifest.xml'
applicationPackage = 'com.energymeter'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
}
}
eclipse {
classpath {
downloadSources=true
downloadJavadoc=true
}
}
repositories {
jcenter()
mavenCentral()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases/'
}
}
ext.GLUON_VERSION = "2.1.0"
dependencies {
/*************** GLUON **************************/
compile 'org.javafxports:jfxdvk:8.60.7'
compile 'com.airhacks:afterburner.mfx:1.6.2'
compile "com.gluonhq:charm:$GLUON_VERSION"
androidRuntime "com.gluonhq:charm-android:$GLUON_VERSION"
iosRuntime "com.gluonhq:charm-ios:$GLUON_VERSION"
desktopRuntime "com.gluonhq:charm-desktop:$GLUON_VERSION"
/*************** ORMLITE **************************/
compile 'com.j256.ormlite:ormlite-core:4.48'
androidCompile 'com.j256.ormlite:ormlite-android:4.48'
desktopCompile 'com.j256.ormlite:ormlite-jdbc:4.48'
desktopCompile "org.xerial:sqlite-jdbc:3.8.11.2"
desktopCompile 'org.xerial.thirdparty:nestedvm:1.0'
/*************** DIVERS **************************/
compile files('lib/jfoenix-0.0.0-SNAPSHOT-retrolambda.jar')
compile 'de.jensd:fontawesomefx:8.8' /*8.9 verwendet invokeDynamic*/
compile 'org.joda:joda-money:0.11'
compile 'net.sf.supercsv:super-csv:2.4.0'
compile 'org.slf4j:slf4j-api:1.7.16'
desktopRuntime 'ch.qos.logback:logback-classic:1.1.5'
androidRuntime('com.github.tony19:logback-android-classic:1.1.1-4'){
exclude group: 'com.google.android', module: 'android'}
androidRuntime 'com.github.tony19:logback-android-core:1.1.1-4'
/*************** TEST *****************************/
testCompile 'junit:junit:4.12'
}
logcat output:
04-01 18:14:45.790: E/FXEntity(16186): call native MultitouchEvent, density = 1.5, touchXs0 = 436
04-01 18:14:45.790: I/GLASS(16186): Call InternalSurfaceView_onMultiTouchEventNative
04-01 18:14:45.790: I/GLASS(16186): Glass will pass multitouchevent to monocle with count = 1
04-01 18:14:45.840: E/FXEntity(16186): call native MultitouchEvent, density = 1.5, touchXs0 = 436
04-01 18:14:45.860: I/GLASS(16186): Call InternalSurfaceView_onMultiTouchEventNative
04-01 18:14:45.860: I/GLASS(16186): Glass will pass multitouchevent to monocle with count = 1
04-01 18:14:45.870: I/System.out(16186): don't add points, primary = -1
04-01 18:14:46.020: E/dalvikvm(16186): GC_FOR_ALLOC freed 4580K, 26% free 15699K/21127K, paused 20ms+5ms, total 113ms
04-01 18:14:46.210: E/dalvikvm(16186): GC_CONCURRENT freed 3K, 7% free 19665K/21127K, paused 14ms+15ms, total 194ms
04-01 18:14:46.870: I/System.out(16186): PPSRenderer: scenario.effect - createShader: LinearConvolve_12
04-01 18:14:46.940: V/FXEntity(16186): surfacetextureupdated...
04-01 18:14:47.040: V/FXEntity(16186): surfacetextureupdated...
04-01 18:14:47.110: V/FXEntity(16186): surfacetextureupdated...
04-01 18:14:48.770: E/FXEntity(16186): call native MultitouchEvent, density = 1.5, touchXs0 = 270
04-01 18:14:48.770: I/GLASS(16186): Call InternalSurfaceView_onMultiTouchEventNative
04-01 18:14:48.770: I/GLASS(16186): Glass will pass multitouchevent to monocle with count = 1
04-01 18:14:48.820: E/FXEntity(16186): call native MultitouchEvent, density = 1.5, touchXs0 = 270
04-01 18:14:48.840: I/GLASS(16186): Call InternalSurfaceView_onMultiTouchEventNative
04-01 18:14:48.840: I/GLASS(16186): Glass will pass multitouchevent to monocle with count = 1
04-01 18:14:48.840: I/System.out(16186): don't add points, primary = -1
04-01 18:14:48.870: V/FXEntity(16186): surfacetextureupdated...
04-01 18:14:49.510: E/dalvikvm(16186): GC_CONCURRENT freed 5927K, 30% free 15939K/22663K, paused 15ms+22ms, total 286ms
04-01 18:14:49.990: E/dalvikvm(16186): GC_CONCURRENT freed 659K, 29% free 16213K/22663K, paused 14ms+19ms, total 206ms
04-01 18:14:50.460: E/dalvikvm(16186): GC_CONCURRENT freed 584K, 27% free 16561K/22663K, paused 14ms+9ms, total 219ms
04-01 18:14:50.820: V/FXEntity(16186): Called notify_showIME
04-01 18:14:50.820: V/FXEntity(16186): Done calling notify_showIME
04-01 18:14:51.060: W/dalvikvm(16186): VFY: unable to resolve static method 38363: Ljava/lang/Math;.floorMod (II)I
04-01 18:14:51.080: E/dalvikvm(16186): GC_CONCURRENT freed 703K, 26% free 16827K/22663K, paused 15ms+19ms, total 357ms
04-01 18:14:51.250: I/System.out(16186): meterskin layout children
04-01 18:14:51.470: I/System.out(16186): ES2ResourceFactory: Prism - createStockShader: FillRoundRect_Color.frag
04-01 18:14:51.510: I/System.out(16186): Loading Prism common native library ...
04-01 18:14:51.510: I/System.out(16186): succeeded.
04-01 18:14:51.640: I/System.out(16186): PPSRenderer: scenario.effect - createShader: LinearConvolveShadow_32
04-01 18:14:51.670: E/dalvikvm(16186): GC_CONCURRENT freed 531K, 20% free 18185K/22663K, paused 14ms+10ms, total 151ms
04-01 18:14:51.710: I/System.out(16186): PPSRenderer: scenario.effect - createShader: PhongLighting_DISTANT
04-01 18:14:51.740: I/System.out(16186): PPSRenderer: scenario.effect - createShader: ColorAdjust
04-01 18:14:51.820: I/System.out(16186): ES2ResourceFactory: Prism - createStockShader: AlphaTexture_LinearGradient.frag
04-01 18:15:01.700: E/dalvikvm(16186): GC_CONCURRENT freed 1076K, 19% free 18448K/22663K, paused 23ms+6ms, total 163ms
04-01 18:15:22.260: E/dalvikvm(16186): GC_CONCURRENT freed 1462K, 19% free 18445K/22663K, paused 24ms+6ms, total 156ms
04-01 18:15:42.930: E/dalvikvm(16186): GC_CONCURRENT freed 1465K, 19% free 18445K/22663K, paused 23ms+6ms, total 174ms

Related

DWM Leaks Memory When No Monitor Connected Windows 8

Simply, if no monitor connected and you are doing some "windows" operation on windows 8 embedded, dwm.exe starts allocating memory and never stops.
to regenerate and show you all the problem, i have written an application which is doing "Create a new Form and show it, if there is one created close it first"
public partial class PopupWindows : Form
{
private Timer _t;
private Form _form;
public PopupWindows()
{
InitializeComponent();
this.Size = new Size(500, 500);
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
_t = new Timer();
_t.Tick += (o, ea) =>
{
_form?.Close();
(_form = new Form() { Size = this.Size }).Show();
};
_t.Interval = 1000;
_t.Enabled = true;
}
}
if you run this application and plug out the monitor, dwm start allocating pages
here is the output from pslist -m when the monitor connected
Name Pid VM WS Priv Priv Pk Faults NonP Page
dwm 840 123528 14400 11264 13044 55125 7 212
after some time but still the monitor connected
dwm 840 117144 15808 12732 13044 94051 7 200
disconnecting monitor and dwm.exe start allocating
dwm 840 214660 14444 12664 13044 137409 13 400
below is the output where you can see allocation dwm.exe doing
C:\PSTools>pslist.exe -m|findstr "dwm"
dwm 840 251956 14460 12740 13044 137413 16 477
C:\PSTools>pslist.exe -m|findstr "dwm"
dwm 840 251956 14460 12740 13044 137413 16 477
C:\PSTools>pslist.exe -m|findstr "dwm"
dwm 840 251956 14460 12740 13044 137413 16 477
C:\PSTools>pslist.exe -m|findstr "dwm"
dwm 840 252964 14460 12740 13044 137413 16 479
C:\PSTools>pslist.exe -m|findstr "dwm"
dwm 840 252964 14460 12740 13044 137413 16 479
C:\PSTools>pslist.exe -m|findstr "dwm"
dwm 840 253972 14460 12744 13044 137413 16 481
C:\PSTools>pslist.exe -m|findstr "dwm"
dwm 840 253972 14460 12744 13044 137413 16 481
C:\PSTools>pslist.exe -m|findstr "dwm"
dwm 840 254980 14460 12744 13044 137413 16 483
and this strange act dwm doing never stops till you connect a monitor or doing vnc connection to the computer.
after some time on operation without monitor, every os component starts to complain about memory and a blue screen of death occurs at the end.
let me show you the last one
dwm 840 807516 15624 14216 17240 147413 50 1603
here is the output showing how many minutes my popupwindows.exe running
Name Pid Pri Thd Hnd Priv CPU Time Elapsed Time
PopupWindows 2052 6 4 138 9468 0:00:00.140 0:23:07.332
as you can see, after about 20 minutes without having a monitor on the device, dwm.exe using 807516 bytes VM and 1603 pages.
Acting like what vnc doing (copying whole screen bitmap to application memory regularly) solved the dwm's allocation problem (which i think dwm caches its outputs but no one come and ask for the changes so it keeps all of them in the memory and never cleans).
below is the application which starts hidden and regularly copying screen image into app memory
public partial class HiddenForm : Form
{
IntPtr _this;
private System.Windows.Forms.Timer _timer;
private Bitmap _bmp = null;
public HiddenForm()
{
this.Visible = false;
this.ShowInTaskbar = false;
this.FormBorderStyle = FormBorderStyle.None;
this.HandleCreated += (s, e) => _this = this.Handle;
this.Load += (s, e) => this.Size = new Size(0, 0);
CreateHandle();
CreateControl();
_timer = new System.Windows.Forms.Timer();
_timer.Tick += _timer_Tick;
_timer.Interval = 2000;
_timer.Start();
}
private void _timer_Tick(object sender, EventArgs e)
{
if (Screen.PrimaryScreen == null)
return;
if (_bmp == null)
{
using (Graphics g = CreateGraphics())
{
_bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, g);
}
}
using (Graphics grp = Graphics.FromImage(_bmp))
{
grp.CopyFromScreen(0, 0, 0, 0, _bmp.Size);
}
}
}
here is the output after starting my app
Name Pid VM WS Priv Priv Pk Faults NonP Page
dwm 832 117876 20188 19624 35004 184497 7 185
killing my app with pskill waiting a while
dwm 832 182388 20264 19852 35004 421343 11 317
it starts increasing to re check our app i started it again by typing
C:\HiddenForm.exe
and dwm.exe memory allocation magically downed.
dwm 832 126384 27900 27364 35144 556729 7 187

Update air temperature continuously on Weave Hvac host device

I have an Hvac host device (see interface below) connected to Weave using Libiota and I'm having some trouble understanding how to update the current ambient air temperature (measured on the device). I can measure it but I don't know how to update the state continuously so my Weave client displays the latest ambient air temperature.
I don't fully understand this implementation note in the documentation:
"Changes to the measured ambient temperature should be reported to the
cloud service when the temperature value changes by the minimum level
of granularity for the device UI, for example in 0.5 or 1 degree. If
the device does not support event-based reporting and utilizes
polling, the device should confirm a temperature value change of 0.5
or 1 degree, whichever is the UI's level of granularity, and update
the cloud service at most once every 90 seconds."
I'm able to update the current air temperature at device initialization (inside hvac_controller.c) and upon set temperature setting (i.e. when the heating temperature changes -inside hvac_controller_traits.c-). I'm using this to update the ambient air temperature: IOTA_MAP_SET(ambient_air_temperature_state, degrees_celsius, myvalue);
Interface:
// Create the example hvac controller interface.
g_hvac_controller = GoogHvacControllerDevice_create(
GoogHvacControllerDevice_WITH_AMBIENT_AIR_TEMPERATURE |
GoogHvacControllerDevice_WITH_AMBIENT_AIR_HUMIDITY |
GoogHvacControllerDevice_WITH_DISPLAY_UNITS |
GoogHvacControllerDevice_WITH_HEAT_SUBSYSTEM |
GoogHvacControllerDevice_WITH_HEAT_SETTING);
After understanding that the device (and not Weave) should poll and update the air temperature state with IOTA_MAP_SET(), I tackled this with a pthread.
Here's my main.c
...
#include <pthread.h>
// Function ran by background thread
void *update_air_temperature() {
GoogTempSensor* ambient_air_temperature =
GoogHvacControllerDevice_get_ambient_air_temperature(g_hvac_controller);
GoogTempSensor_State* ambient_air_temperature_state =
GoogTempSensor_get_state(ambient_air_temperature);
while(1) {
// Update air temperature state every 90 seconds
// Read air temperature from sensor
// Code to read sensor and assign value to air_temperature
float air_temperature;
...
// Update air temperature state
IOTA_MAP_SET(ambient_air_temperature_state, degrees_celsius, air_temperature);
sleep(90);
}
return NULL;
}
static IotaDaemon* create_hvac_controller_daemon_(void) {
IOTA_LOG_INFO("Inside create_hvac_controller_daemon_");
// Create the example hvac controller interface.
g_hvac_controller = GoogHvacControllerDevice_create(
GoogHvacControllerDevice_WITH_AMBIENT_AIR_TEMPERATURE |
GoogHvacControllerDevice_WITH_AMBIENT_AIR_HUMIDITY |
GoogHvacControllerDevice_WITH_DISPLAY_UNITS |
GoogHvacControllerDevice_WITH_HEAT_SUBSYSTEM |
GoogHvacControllerDevice_WITH_HEAT_SETTING);
IotaDevice* iota_device = iota_device_create_from_interface(
(IotaInterface*)g_hvac_controller, (IotaModelManifestId){"AHXXX"});
if (iota_device == NULL) {
IOTA_LOG_ERROR("Device create from interface failed");
GoogHvacControllerDevice_destroy(g_hvac_controller);
return NULL;
}
g_iota_daemon = host_framework_create_daemon("hvac_controller", iota_device);
// Set default state of traits on the hvac_controller.
example_hvac_controller_configure(g_hvac_controller, g_iota_daemon,
"Heating");
// Background thread to update air temperature
pthread_t thread1;
pthread_create(&thread1, NULL, update_air_temperature, NULL);
return g_iota_daemon;
}
int main(int argc, char** argv) {
HostIotaFrameworkConfig config = (HostIotaFrameworkConfig){
.base =
(IotaFrameworkConfig){
.cli_commands = NULL,
.num_commands = 0,
.builder = create_hvac_controller_daemon_,
},
.argc = argc,
.argv = argv,
.user_data = NULL,
.name = "hvac controller",
};
return host_framework_main(&config);
}
Don't forget to add -lpthread to the makefile:
...
EXTRA_LIBS=-lpthread
EXAMPLE_OUT_DIR := $(ARCH_OUT_DIR)/examples/$(EXAMPLE)
...
$(EXAMPLE_BIN): $(LIBIOTA_STATIC_LIB) $(PLATFORM_STATIC_LIB) \
$(EXAMPLES_COMMON_LIB) $(HOST_DEVFW_LIB) \
$(EXAMPLE_OBJECTS) | $(EXAMPLE_OUT_DIR)
$(CC) -Wl,--start-group $^ -Wl,--end-group -o $# $(LDLIBS) $(PLATFORM_LDLIBS) $(EXTRA_LIBS)
...
Keep in mind that you should only report the new air temperature when it changes, and at a max frequency of 90 seconds. From the documentation:
Changes to the measured ambient temperature should be reported to the
cloud service when the temperature value changes by the minimum level
of granularity for the device UI, for example in 0.5 or 1 degree. If
the device does not support event-based reporting and utilizes
polling, the device should confirm a temperature value change of 0.5
or 1 degree, whichever is the UI's level of granularity, and update
the cloud service at most once every 90 seconds.
Changing libiota-owned state from outside of the daemon thread could cause trouble. You should use host_iota_daemon_queue_application_job to post a callback to be invoked on the libiota daemon thread, rather than call IOTA_MAP_SET directly from your application thread.

World of Warcraft UI - custom frame without addon

In World Of Warcraft I have created a little coords script that outputs current coords:
local function ou(self,elapsed)
px,py=GetPlayerMapPosition("player")
DEFAULT_CHAT_FRAME:AddMessage(format("( %s ) [%f , %f]",GetZoneText(), px *100, py *100))
end
local f = CreateFrame("frame")
f:SetScript("OnUpdate", ou)
This however spams default chat frame...
How would I create custom frame and how would I access it?
(I can't use custom channel with SendChatMessage)
...I would like to do this WITHOUT making an addon, thanks :)
I found a solution in storing frame in global variable, as I don't intend to create a plugin, the whole program requires a few macros (macro's maximum number of characters is 255).
First macro - prepare function that will set frame attributes later
f = input frame that will be set
x = x coordinate of position
y = y coordinate of position
function setMyFrame(f,x,y)
f:SetSize(288,100)
f:SetPoint("TOPLEFT",UIParent,"TOPLEFT",x,y)
f.text = f.text or f:CreateFontString(nil,"ARTWORK","QuestFont_Shadow_Huge")
f.text:SetAllPoints(true)
end
Second macro - prepare coords function that will set current coords as frame's text
ctotel = time elapsed since last update of the frame
creft = how often should the frame be updated in SECONDS - good one is 0.1 - 10 times a second is performance friendly and fast enaugh to coords update
f = input frame that will be updated
i = "how long it's been since the last update call cycle" (you don't set that - it is inherited from the WoW system)
ctotel = 0
creft = 0.1
function myCoords(f,i)
ctotel = ctotel + i
if ctotel >= creft then
px,py=GetPlayerMapPosition("player")
f.text:SetText(format("( %s ) [%f , %f]",GetZoneText(), px *100, py *100))
ctotel = 0
end
end
Third macro - store frame in global variable and set it and run update script with myCoords as callback
myCoordsFrame = CreateFrame("Frame","MyCoordsFrame",UIParent)
setMyFrame(myCoordsFrame, 500, 0)
myCoordsFrame:SetScript("OnUpdate", myCoords)
Of course in game all macros have to be preceeded with /run and have to be inlined - no line breaks - instead of linebreak just make space...
Also you have to run macros in THIS ^^^ order (first=>second=>third)
Advantage in setting frame and creft as globals:
Frames can't be destroyed while in the world (you have to relog to destroy them) so when it's global you can later move it with
/run setMyFrame(myCoordsFrame, NEW_X_COORDINATE, NEW_Y_COORDINATE)
If you would like the coords to update slower/faster you can do it by resetting the creft - e.g. to almost realtime refresh every 0.05 or even 0.01 seconds:
/run creft = 0.05 ... or even /run creft = 0.01
Make Coords movable - draggable by left mouse (credit to Wanderingfox from WoWhead):
myCoordsFrame:SetMovable(true)
myCoordsFrame:EnableMouse(true)
myCoordsFrame:SetScript("OnMouseDown",function() myCoordsFrame:StartMoving() end)
myCoordsFrame:SetScript("OnMouseUp",function() myCoordsFrame:StopMovingOrSizing() end)
...and as copy-paste ingame macro:
/run myCoordsFrame:SetMovable(true) myCoordsFrame:EnableMouse(true) myCoordsFrame:SetScript("OnMouseDown",function() myCoordsFrame:StartMoving() end) myCoordsFrame:SetScript("OnMouseUp",function() myCoordsFrame:StopMovingOrSizing() end)

MKMapView setRegion: animated: crashes the app (edited)

I have a MKMapView that expands (vertically) on tap (using UITapGestureRecognizer) and fires off an api call on pan (using UIPanGestureRecoginizer).
Everything was working fine, until some time back, where on Panning, the app would crash, with hardly any useful info (or info that I could comprehend)
Exception breakpoints are on, and zombie objects have been enabled. On crashing, it never hits the exception breakpoint!
Here's the log:
(Panning began, panning, panning ended are printed out based on the Pan gestureRecognizer states).
Right after panning ends, the app crashes.
(The map is yet to load all its tiles, and regionDidChangeAnimated is not called yet):
2013-01-17 14:46:04.396 MyApp[13126:c07] Panning Began
2013-01-17 14:46:04.412 MyApp[13126:c07] Panning
2013-01-17 14:46:04.412 MyApp[13126:c07] Panning
2013-01-17 14:46:04.557 MyApp[13126:c07] Panning
2013-01-17 14:46:04.606 MyApp[13126:c07] Panning
2013-01-17 14:46:04.691 MyApp[13126:c07] Panning Ended
2013-01-17 14:46:04.692 MyApp[13126:c07] *** -[MKMapViewPositioningChange hasChanges]: message sent to deallocated instance 0x139f7520
Here's the backtrace i see after the crash:
(lldb) bt
* thread #1: tid = 0x1c03, 0x02a4fa97 CoreFoundation`___forwarding___ + 295, stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
frame #0: 0x02a4fa97 CoreFoundation`___forwarding___ + 295
frame #1: 0x02a4f94e CoreFoundation`_CF_forwarding_prep_0 + 14
frame #2: 0x01244d27 MapKit`-[MKMapView(UserPositioningInternal) _runPositioningChange] + 2037
frame #3: 0x01242dd7 MapKit`-[MKMapView(UserPositioningInternal) _runPositioningChangeIfNeeded:] + 86
frame #4: 0x01240220 MapKit`-[MKMapViewInternal runPositioningChangeIfNeeded] + 50
frame #5: 0x01e2eb90 Foundation`__NSFireTimer + 97
frame #6: 0x02a1f376 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
frame #7: 0x02a1ee06 CoreFoundation`__CFRunLoopDoTimer + 534
frame #8: 0x02a06a82 CoreFoundation`__CFRunLoopRun + 1810
frame #9: 0x02a05f44 CoreFoundation`CFRunLoopRunSpecific + 276
frame #10: 0x02a05e1b CoreFoundation`CFRunLoopRunInMode + 123
frame #11: 0x03c897e3 GraphicsServices`GSEventRunModal + 88
frame #12: 0x03c89668 GraphicsServices`GSEventRun + 104
frame #13: 0x0132d65c UIKit`UIApplicationMain + 1211
frame #14: 0x0001223d MyApp`main + 141 at main.m:16
frame #15: 0x00002fc5 MyApp`start + 53
The crashes go away the moment i take the connection for the PanGestureRecognizer action method.
Is there a way to get rid of this crash while using the gesture recognizers? or is there a way to know that the map was tapped and panned, without using GestureRecognizers?
Any help/questions/answers/comments appreciated!
Update (Jan 19): This doesn't seem to be an issue with the pan gesture recognizer at all. Now I am getting it to crash on after i try to add new annotations to the mapview, call [MapView setRegion: animated:], and crashes just before regionDidChangeAnimated is hit, with the same [MKMapViewPositioningChange hasChanges] log at the point where it crashes.
Update (Jan 23): I think I am quite sure whats happening. there is one chunk of code thats trying to set the region to include all the annotations in the visible rect of the MKMapView, and a few other locations, where I am calling [myMapView removeAnnotations:[myMapView annotations]]. And, my guess is that these two actions end up in a nasty mid-air collision, leaving no trail as to what lead to a crash. Will update the question with an answer if my hunch-fix passes QA
As I had guessed earlier (second update to the question), this was an issue with trying the add set the map region to show all annotations, and removing all annotations simultaneously. if you are calling setRegion: animated: , make sure to check if the mapView has at least one annotation.
Also, it'll be helpful to use the following piece of code judiciously, especially if you are doing any type of animations on the map based on the annotations.
[MKMapView removeAnnotations:[MKMapView annotations]];

Matlab GUI Design Optical Effects (Transition)

I have designed a GUI with uitabs. I want to achieve a smooth transition (optical effect) when the selected tab is changed. For it, I write the following callback:
function SelectionChangeCbk(src,evt)
oldTab = evt.OldValue;
newTab = evt.NewValue;
set([oldTab,newTab],'Visible','off');
drawnow;
pause(2);
set(newTab,'Visible','on');
end
However, I can get my target because this does not work (I have two tabs. The selected tab before the change is called oldTab and the new tab, selected after the change, is called newTab. I want that when I change from oldTab to newTab, first oldTab and newTab becomes invisible, then waiting for two seconds before newTab appears).
I have tried the application WindowAPI but it only works with figure handles.
P.D.: Here is the complete code:
function AA
fh = figure('Units','characters','Position',[-200.2 -77 214.8 46.154],...
'Menu','none','Toolbar','none','NumberTitle','off');
movegui(fh,'center');
warning off MATLAB:uitabgroup:OldVersion % turn off warning
htab = uitabgroup('Parent',fh,'BackgroundColor','k',...
'SelectionChangeCallback',#SelectionChangeCbk);
th1 = uitab('parent',htab,'title','Tab#1');
hPan1 = uipanel(th1,'title','Panel1','Units','characters',...
'Position',[27.24 27.163 217.92 13.038],'BorderType','line',...
'ForegroundColor','w','BackgroundColor','k');
uicontrol(hPan1,'Style','text','String','Text#1',...
'Units','normalized','Position',[0.117 0.617 0.208 0.128],...
'ForegroundColor','w','BackgroundColor','k');
uicontrol(hPan1,'Style','edit','String','300','Units',...
'normalized','Position',[0.354 0.623 0.228 0.128],...
'ForegroundColor','k','BackgroundColor','w');
uicontrol(hPan1,'Style','text','String','Text#2',...
'Units','normalized','Position',[0.156 0.248 0.166 0.128],...
'ForegroundColor','w','BackgroundColor','k');
uicontrol(hPan1,'Style','edit','String','1000','Units',...
'normalized','Position',[0.354 0.259 0.228 0.128],...
'ForegroundColor','k','BackgroundColor','w');
hPan2 = uipanel(th1,'title','Panel2','Units',...
'characters','Position',[27.24 7 217.92 13.038],...
'ForegroundColor','w','BackgroundColor','k','BorderType','line');
uicontrol(hPan2,'Style','text','String',...
'Text#3','Units','normalized',...
'Position',[0.112 0.632 0.215 0.128],'ForegroundColor',...
'w','BackgroundColor','k');
uicontrol(hPan2,'Style','edit','String','100','Units',...
'normalized','Position',[0.354 0.618 0.228 0.148],'ForegroundColor',...
'k','BackgroundColor','w');
uicontrol(hPan2,'Style','text','String','Text#4',...
'Units','normalized','Position',[0.171 0.248 0.15 0.128],'FontSize',...
9,'ForegroundColor','w','BackgroundColor','k');
uicontrol(hPan2,'Style','edit','String','100','Units',...
'normalized','Position',[0.354 0.235 0.228 0.148],...
'ForegroundColor','k','BackgroundColor','w');
th2 = uitab('parent',htab,'title','Tab#2','Units',...
'characters');
hPan3 = uipanel(th2,'title','Panel3','Units','characters',...
'Position',[4.248 24.462 217.552 16.923],'ForegroundColor','w',...
'BackgroundColor','k');
hPan31 = uipanel(hPan3,'title','Panel 3.1','Units','normalized',...
'Position',[0.017 0.13 0.496 0.816],'ForegroundColor','w',...
'BackgroundColor','k','BorderType','line');
uicontrol(hPan31,'Style','text','String','Text311','Units',...
'normalized','Position',[0.079 0.711 0.34 0.171],'FontSize',9,...
'ForegroundColor','w','BackgroundColor','k');
uicontrol(hPan31,'Style','edit','String','1000',...
'Units','normalized','Position',...
[0.455 0.8 0.242 0.099],'ForegroundColor','k',...
'BackgroundColor','w');
uicontrol(hPan31,'Style','edit','String','1000',...
'Units','normalized','Position',[0.455 0.451 0.241 0.133],...
'ForegroundColor','k','BackgroundColor','w');
uicontrol(hPan31,'Style','text','String','Label','Units','normalized',...
'Position',[0.741 0.437 0.101 0.151],'ForegroundColor',...
'w','BackgroundColor','k');
uicontrol(hPan31,'Style','edit','String','4','Units',...
'normalized','Position',[0.862 0.458 0.1 0.133],'ForegroundColor',...
'k','BackgroundColor','w');
hPan32 = uipanel(hPan3,'title','Panel 3.2','Units',...
'normalized','Position',[0.53 0.13 0.231 0.816],...
'ForegroundColor','w','BackgroundColor','k','BorderType',...
'line');
uicontrol(hPan32,'Style','text','String','TEXT34',...
'Value',0,'Units','normalized','Position',[0.094 0.483 0.443 0.133],...
'FontSize',9,'ForegroundColor','w','BackgroundColor','k');
uicontrol(hPan32,'Style','edit','String','10',...
'Units','normalized','Position',[0.63 0.47 0.275 0.133],'FontSize',...
9,'ForegroundColor','k','BackgroundColor','w');
hPan33 = uipanel(hPan3,'title','Panel 3.3','Units',...
'normalized','Position',[0.778 0.13 0.205 0.816],...
'ForegroundColor','w','BackgroundColor','k','BorderType','line');
uicontrol(hPan33,'Style','text','String','TEXT34',...
'Value',0,'Units','normalized','Position',[0.094 0.483 0.443 0.133],...
'FontSize',9,'ForegroundColor','w','BackgroundColor','k');
uicontrol(hPan33,'Style','edit','String','10',...
'Units','normalized','Position',[0.63 0.47 0.275 0.133],'FontSize',...
9,'ForegroundColor','k','BackgroundColor','w');
hPan4 = uipanel(th2,'title','Panel 4','Units','characters',...
'Position',[4.248 0.831 264.228 27],'ForegroundColor','w',...
'BackgroundColor','k');
hPan41 = uipanel(hPan4,'title','Panel 4.1','Units','normalized',...
'Position',[0.012 0.521 0.3 0.48],'ForegroundColor','w',...
'BackgroundColor','k','BorderType','line');
uicontrol(hPan41,'Style','text','String','TEXT34',...
'Value',0,'Units','normalized','Position',[0.094 0.483 0.443 0.133],...
'FontSize',9,'ForegroundColor','w','BackgroundColor','k');
uicontrol(hPan41,'Style','edit','String','10',...
'Units','normalized','Position',[0.63 0.47 0.275 0.133],'FontSize',...
9,'ForegroundColor','k','BackgroundColor','w');
% Subpanel "Intervalo de anĂ¡lisis"
hPan42 = uipanel(hPan4,'title','Panel 4.2','Units',...
'normalized','Position',[0.012 0.02 0.3 0.48],'ForegroundColor','w',...
'BackgroundColor','k','BorderType','line');
uicontrol(hPan42,'Style','text','String','TEXT34',...
'Value',0,'Units','normalized','Position',[0.094 0.483 0.443 0.133],...
'FontSize',9,'ForegroundColor','w','BackgroundColor','k');
uicontrol(hPan42,'Style','edit','String','10',...
'Units','normalized','Position',[0.63 0.47 0.275 0.133],'FontSize',...
9,'ForegroundColor','k','BackgroundColor','w');
hPan43 = uipanel(hPan4,'title','Panel 4.3',...
'Units','normalized','Position',[0.324 0.02 0.261 0.98],...
'ForegroundColor','w','BackgroundColor','k','BorderType','line');
uicontrol(hPan43,'Style','text','String','TEXT34',...
'Value',0,'Units','normalized','Position',[0.094 0.483 0.443 0.133],...
'FontSize',9,'ForegroundColor','w','BackgroundColor','k');
uicontrol(hPan43,'Style','edit','String','10',...
'Units','normalized','Position',[0.63 0.47 0.275 0.133],'FontSize',...
9,'ForegroundColor','k','BackgroundColor','w');
hPan44 = uipanel(hPan4,'title','Panel 4.4',...
'Units','normalized','Position',[0.597 0.02 0.391 0.98],...
'ForegroundColor','w','BackgroundColor','k','BorderType','line');
uicontrol(hPan44,'Style','text','String','TEXT34',...
'Value',0,'Units','normalized','Position',[0.094 0.483 0.443 0.133],...
'FontSize',9,'ForegroundColor','w','BackgroundColor','k');
uicontrol(hPan44,'Style','edit','String','10',...
'Units','normalized','Position',[0.63 0.47 0.275 0.133],'FontSize',...
9,'ForegroundColor','k','BackgroundColor','w');
function SelectionChangeCbk(src,evt)
oldTab = evt.OldValue;
newTab = evt.NewValue;
set([oldTab,newTab],'Visible','off');
drawnow;
pause(2);
set(newTab,'Visible','on');
end
end
I would not use uitabgroup. It is not documented, and its behavior is undefined. Instead, consider using the GUI Layout toolbox package from Matlab Central. By the way, the visibility is handled there by moving panels to far location unseen on the screen (Like (-100000,-100000) ) - it seems to be more robust than setting visibility.
Anyhow, there is no easy way to achieve smooth fade-in/fade-out transition in Matlab GUI, at least not a documented one.

Resources