Saturday, 26 May 2018

Android NDK throwing signal sigsegv: invalid address in debug mode

I implemented the android NDK recently to hide my app keys and secrets. Since I did that whenever I run my app in debug mode in android studio, my breakpoints get interrupted with sigsegv (signal sigsegv: invalid address (fault address: 0x8)). This occurs when any of my processes access the NDK at all. I'm baffled as to what's happening as I am very new with the NDK. My C code is extremely simple, and looks something like:

#include <jni.h>

JNIEXPORT jstring JNICALL
Java_com_my_company_co_utilities_UtilFuncs_getSecretOne(JNIEnv *env, jobject instance) {
    return (*env)->  NewStringUTF(env, "my_secret_1");
}
JNIEXPORT jstring JNICALL
Java_com_my_company_co_utilities_UtilFuncs_getSecretTwo(JNIEnv *env, jobject instance) {
    return (*env)->  NewStringUTF(env, "my_secret_2");
}
JNIEXPORT jstring JNICALL
JJava_com_my_company_co_utilities_UtilFuncs_getKeyOne(JNIEnv *env, jobject instance) {
    return (*env)->  NewStringUTF(env, "my_key_1");
}

JNIEXPORT jstring JNICALL
Java_com_my_company_co_utilities_UtilFuncs_getKeyTwo(JNIEnv *env, jobject instance) {

    return (*env)->NewStringUTF(env, "my_key_2");
}

and I access it in my static UtilFuncs class like:

static {
        System.loadLibrary("keys");
    }

    public static native String getSecretOne();

    public static String getSecret() {
            return getSecretOne();

    }

It works perfectly when I run the app normally, but it has made debug unusable entirely because of these sigsegv: invalid address errors coming up when I'm trying to read watch variables. Anyone encounter this before or have any idea what I'm doing wrong?



from Android NDK throwing signal sigsegv: invalid address in debug mode

Maphilight() stops working correctly after zoom in/out of imagemap

I have one image map with 300-400 poly areas which on event "onclick" shoud highlight that area and get some data etc... When page is loaded (my images are kinda big, 3-5MB) so I resized those imagemaps using davidjbradshaw/image-map-resizer plugin. When I started to implement highlight method, everything worked fine, but after zoom in/out of image my poly cords are messed up. If I remove highlight option and zoom in/out my poly cords are resized to proper image size.

JS code for resizing (working correctly)

 $( document ).ready(function() {
    imageMapResize();
  });

  function ZoomIn () {
    $("img").animate({
      height: '+=200',
      width: '+=200'
    }, 1000, function() {
      imageMapResize();
    });    
  }

  function  ZoomOut () {
    $("img").animate({
      height: '-=200',
      width: '-=200'
    }, 1000, function() {
      imageMapResize();
    });
  }

JS code for resizing/highlight (not working correctly)

$( document ).ready(function() {
    imageMapResize();
    $('img[usemap]').maphilight();
  });

  function ZoomIn () {
    $("img").animate({
      height: '+=200',
      width: '+=200'
    }, 1000, function() {
      imageMapResize();
      $('img[usemap]').maphilight();
    });
  }

  function  ZoomOut () {
    $("img").animate({
      height: '-=200',
      width: '-=200'
    }, 1000, function() {
      imageMapResize();
      $('img[usemap]').maphilight();
    });
  }

Without zoom in/out imageresizer and highlight works perfect.

initial picture

After zoom in/out

image of missing poly cords

What am I doing wrong?



from Maphilight() stops working correctly after zoom in/out of imagemap

Friday, 25 May 2018

Overlay button on NativeScript TabView?

I have a simple TabView like this using NativeScript w/angular:
<TabView [(ngModel)]="tabSelectedIndex" height="300px" (selectedIndexChanged)="onSelectedIndexChanged($event)">
     <StackLayout *tabItem="{title: 'Tab 1'}">
         <Label text="Content in Tab 1"></Label>
    </StackLayout>
     <StackLayout *tabItem="{title: 'Button 1'}">
         <!-- these won't be content here because clicking this should not change to a another tab,
 but instead should do something else. -->
    </StackLayout>
    <StackLayout *tabItem="{title: 'Tab 2'}">
        <Label text="Content in Tab 2"></Label>
        </StackLayout>
</TabView>

I want a button in the tab bar that doesn't change the view, but instead does something else (such as open a modal dialog).
I tried a new <StackLayout> both inside and outside of <TabView>.
I also tried using an <AbsoluteLayout>. All methods caused the app to crash.
Is it possible to capture the tab view change using selectedIndexChanged and prevent the change?
I tried stopPropagation() on the event but got error: Property 'stopPropagation' does not exist on type 'SelectedIndexChangedEventData'.
I tried changing the view back to the view that existed when the middle button was clicked, but there is a noticeable flicker because the view has to change before this event is even fired. What would have been acceptable is something like onSelectedIndexWill Change but that method does not exist.
 onSelectedIndexChanged(args: SelectedIndexChangedEventData) {
        if (args.newIndex === 1) { //the middle button
            setTimeout(() => {
                tabView.selectedIndex = args.oldIndex; //go back to the previous view (causes flicker)
                //do stuff for the button click.
            });
        }
    }

Or is there another way to incorporate a button in the tab bar that doesn't link to a new view?
Or should I not implement a native tab bar and instead just create a navigation bar from scratch?
Here's how it can be done for ios.
Here is a sample app in NativeScript playground showing the issue. Click center link to see the flicker.


from Overlay button on NativeScript TabView?