Android VM threaded

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Android VM threaded

Michael Rueger
 

after a bit more digging it seems that the getRedzoneSize (sqUnixMain.c) magic doesn't work as expected in Android if it
is called on a non-UI thread.
The behavior isn't consistent, it simply crashes or gives back impossibly large (negative) numbers.

Just for proof of concept I hard coded a value that I got from executing getRedzoneSize on the main thread and the VM
now runs (I see regular calls to invalidate display in the log).

The code in that function is way over my head, so any help appreciated!

Discovered I need to sched_yield, otherwise the display is never updated even though draw is called from the UI thread
after a VM initiated invalidate. Not handling actual display bits yet, hopefully really soon now :-)

Michael


static int
getRedzoneSize()
{
        struct sigaction handler_action, old;
        handler_action.sa_sigaction = sighandler;
        handler_action.sa_flags = SA_NODEFER | SA_SIGINFO;
        sigemptyset(&handler_action.sa_mask);
        (void)sigaction(SIGPROF, &handler_action, &old);

        do kill(getpid(),SIGPROF); while (!p);
        (void)sigaction(SIGPROF, &old, 0);
        return (char *)min(&old,&handler_action) - sizeof(struct sigaction) - p;
}

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Android VM preliminary benchmarks

Michael Rueger
 

MacBook Pro 15
2,904,964,539 bytecodes
203,650,058 sends

Android Samsung Galaxy Tab A
341,105,929 bytecodes
22,367,567 sends

original Android port on Samsung Galaxy Tab A
26,890,756 bytecodes
795,403 sends
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Android VM preliminary benchmarks

David T. Lewis
 
On Tue, Jun 27, 2017 at 12:01:36AM +1200, Michael Rueger wrote:

>
>
> MacBook Pro 15
> 2,904,964,539 bytecodes
> 203,650,058 sends
>
> Android Samsung Galaxy Tab A
> 341,105,929 bytecodes
> 22,367,567 sends
>
> original Android port on Samsung Galaxy Tab A
> 26,890,756 bytecodes
> 795,403 sends

Outstanding!

Dave

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Android VM preliminary benchmarks

Bert Freudenberg
 

On Mon 26. Jun 2017 at 14:41, David T. Lewis <[hidden email]> wrote:

On Tue, Jun 27, 2017 at 12:01:36AM +1200, Michael Rueger wrote:
>
>
> MacBook Pro 15
> 2,904,964,539 bytecodes
> 203,650,058 sends
>
> Android Samsung Galaxy Tab A
> 341,105,929 bytecodes
> 22,367,567 sends
>
> original Android port on Samsung Galaxy Tab A
> 26,890,756 bytecodes
> 795,403 sends

Outstanding!

Dave

Awesome!

What flavor of VM is this? Stack, Cog, Spur, Sista?

- Bert -

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Android VM preliminary benchmarks

Michael Rueger
 

>
> What flavor of VM is this? Stack, Cog, Spur, Sista?

good point :-)
CogSpur

It is even with optimizations turned off for debugging, forgot about that...

add_definitions(
        -DANDROID
        -DVM_TARGET_OS="android"
        -DVM_TARGET_CPU="armeabi-v7a"
  -DNOEXECINFO
        -DAVOID_OPENGL_H
        -DFT2_BUILD_LIBRARY
        -DVM_TICKER=1

        -DUSE_GLOBAL_STRUCT=0
        -DITIMER_HEARTBEAT=1
        -DSPURVM
        -D_GNU_SOURCE
        -DNDEBUG
        -DCOGMTVM=0
# -DDEBUGVM=0
        -DLSB_FIRST=1
# -DNO_VM_PROFILE=1

# -g0 -O2
        -g
        -m32
        )

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Android VM threaded

Michael Rueger
In reply to this post by Michael Rueger
 
Hi all,

so continuing on with the below mentioned hack I got a version running that correctly displays colors (although not the
image desktop image) and accepts mouse/touch input.

If you hit the back button the next touch will be interpreted as right button click.

There is still something wrong with the display endianess, have to swap the bytes for display.

Display updates are done directly from the VM async via SurfaceView, avoids some of the bit copying.

Events are also directly sent from Android and added to the queue, but still polled from the queue within the VM.

Not handling rotation or backgrounding yet, needs a bit more work.

Please feel free to take a look at the code in https://github.com/mrueger42/st-android (development branch), project
CogDroid.

Cheers

Michael


On 26/06/17 7:51 PM, Michael Rueger wrote:
>
>
> after a bit more digging it seems that the getRedzoneSize (sqUnixMain.c) magic doesn't work as expected in Android if it
> is called on a non-UI thread.
> The behavior isn't consistent, it simply crashes or gives back impossibly large (negative) numbers.
>
> Just for proof of concept I hard coded a value that I got from executing getRedzoneSize on the main thread and the VM
> now runs (I see regular calls to invalidate display in the log).

device-2017-07-04-151540.png (142K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Android VM threaded

Eliot Miranda-2
 
Michael,

On Mon, Jul 3, 2017 at 8:21 PM, Michael Rueger <[hidden email]> wrote:
 
Hi all,

so continuing on with the below mentioned hack I got a version running that correctly displays colors (although not the image desktop image) and accepts mouse/touch input.

If you hit the back button the next touch will be interpreted as right button click.

There is still something wrong with the display endianess, have to swap the bytes for display.

Display updates are done directly from the VM async via SurfaceView, avoids some of the bit copying.

Events are also directly sent from Android and added to the queue, but still polled from the queue within the VM.

Not handling rotation or backgrounding yet, needs a bit more work.

Please feel free to take a look at the code in https://github.com/mrueger42/st-android (development branch), project CogDroid.

Congratulations and thank you!  Are you planning to fold the vm changes back into opensmalltalk/vm?

 

Cheers

Michael


On 26/06/17 7:51 PM, Michael Rueger wrote:


after a bit more digging it seems that the getRedzoneSize (sqUnixMain.c) magic doesn't work as expected in Android if it is called on a non-UI thread.
The behavior isn't consistent, it simply crashes or gives back impossibly large (negative) numbers.

Just for proof of concept I hard coded a value that I got from executing getRedzoneSize on the main thread and the VM now runs (I see regular calls to invalidate display in the log).




--
_,,,^..^,,,_
best, Eliot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Android VM threaded

Michael Rueger
 

> Congratulations and thank you!  Are you planning to fold the vm changes back into opensmalltalk/vm?

yes, definitely, that was the idea, was just easier for me to work directly in AndroidStudio first.

Cheers

Michael

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Android VM threaded

Ben Coman
 
Hi Michael,

This is amazingly good timing.  I have an immediate, urgent need for Pharo on Android.  I understand the graphics might not quite be there, but the potential is enticing.  Could I possibly get on a Discord chat and/or Skype with you? 

I'm in the middle of a two week hackathon and needing an Android phone to listen to Bluetooth GAP advertisements from a Raspberry Pi transmitting its GPS coordinates, and then drawing a simple graphic showing the relative location of the transmitter and the phone.  I've had minor success with...  
   https://hackaday.io/project/10314-raspberry-pi-3-as-an-eddystone-url-beacon
using Nicolas Bridoux's "Beacon Scanner" on my Android phone.
What chance do you think a Pharo image has of receiving such events?  I'm about six hours old with Android Studio, done the FirstApp tutorial (https://developer.android.com/training/basics/firstapp/index.html)
and right now working through the Graphics/Aninamation tute (https://developer.android.com/training/building-graphics.html)  but much rather be working in Pharo.  

The benefit for the community is I get to promote Pharo to BHP's new formed Technology group.  BHP are a fortune 500 company putting on ~2000 people globally to work on Industrial Internet Of Things.  There are some really interesting graphs in this video...

Even if the hackthon is too time constrained to get something working, I hope to be able to follow up with BHP to demonstrate Pharo and seek their support for it.

What timezone are you?  I'm GMT+8, but I'm a night owl happy to work around the clock.

cheers -ben

Skype: Ben Coman, Collie, (Western) Australia.


On Thu, Jul 6, 2017 at 3:31 AM, Michael Rueger <[hidden email]> wrote:


Congratulations and thank you!  Are you planning to fold the vm changes back into opensmalltalk/vm?

yes, definitely, that was the idea, was just easier for me to work directly in AndroidStudio first.

Cheers

Michael


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Android VM threaded

Michael Rueger
 
Hi Ben,

as much as I hate to do this, but I think at this point Pharo/Squeak on Android is simply not an option.

You can't code on the device yet (no keyboard input) and for any real work you would need to remote (VNC) into the image
anyways. But, also no working sockets yet. And no JNI support.

With the limited time you have, Android native is your better bet. I'm also pretty sure Mr. Google will find decent
examples for your problems to start with. Never worked with anything bluetooth myself yet on Android, so I'm of no help
here, unfortunately.

Good luck with the project!
Will be happy to help you with any demo at a later point, when things are actually working.

Cheers

Michael


> This is amazingly good timing.  I have an immediate, urgent need for Pharo on Android.  I understand the graphics might
> not quite be there, but the potential is enticing.  Could I possibly get on a Discord chat and/or Skype with you?
>
> I'm in the middle of a two week hackathon and needing an Android phone to listen to Bluetooth GAP advertisements from a
> Raspberry Pi transmitting its GPS coordinates, and then drawing a simple graphic showing the relative location of the
> transmitter and the phone.  I've had minor success with...
> https://hackaday.io/project/10314-raspberry-pi-3-as-an-eddystone-url-beacon 
> <https://hackaday.io/project/10314-raspberry-pi-3-as-an-eddystone-url-beacon>
> using Nicolas Bridoux's "Beacon Scanner" on my Android phone.
> https://github.com/Bridouille/android-beacon-scanner <https://github.com/Bridouille/android-beacon-scanner>
>
> What chance do you think a Pharo image has of receiving such events?  I'm about six hours old with Android Studio, done
> the FirstApp tutorial (https://developer.android.com/training/basics/firstapp/index.html 
> <https://developer.android.com/training/basics/firstapp/index.html>)
> and right now working through the Graphics/Aninamation tute
> (https://developer.android.com/training/building-graphics.html 
> <https://developer.android.com/training/building-graphics.html>)  but much rather be working in Pharo.
>
> The benefit for the community is I get to promote Pharo to BHP's new formed Technology group.  BHP are a fortune 500
> company putting on ~2000 people globally to work on Industrial Internet Of Things.  There are some really interesting
> graphs in this video...
> https://unearthed.solutions/digital-tribes-perth/ <https://unearthed.solutions/digital-tribes-perth/>
>
> Even if the hackthon is too time constrained to get something working, I hope to be able to follow up with BHP to
> demonstrate Pharo and seek their support for it.
>
> What timezone are you?  I'm GMT+8, but I'm a night owl happy to work around the clock.
>
> cheers -ben
>
> Skype: Ben Coman, Collie, (Western) Australia.
>
>
> On Thu, Jul 6, 2017 at 3:31 AM, Michael Rueger <[hidden email] <mailto:[hidden email]>> wrote:
>
>
>
>         Congratulations and thank you!  Are you planning to fold the vm changes back into opensmalltalk/vm?
>
>
>     yes, definitely, that was the idea, was just easier for me to work directly in AndroidStudio first.
>
>     Cheers
>
>     Michael
>
>
Loading...