Page 1 of 2 12 LastLast
Results 1 to 20 of 32
  1.    #1  
    If you make a non-mojo/non-enyo app that's just javascript, css and HTML it loads super fast but for some reason WebOS sends mouse events with a HUGE lag to your app that makes it unusable. Anyone know why?

    Try this below (in an actual phone, e.g. Pre 2) and you'll see the HUGE lag.

    Steps
    ---------
    1. Turn on novacom
    2. Package and install the app
    3. Turn on palm-log -f "<the_name_you_gave_the_app>"
    4. Start the app
    5. Run your finger all over the screen

    The code:

    Index.html (this is the only file you need to alter)
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    	"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    	<title>Test Pure JSJSJS&$lt$;/$title$&$gt$;
    &$lt$;/$head$&$gt$;
    &$lt$;$body$&$gt$;
    	&$lt$;$script$&$gt$;
    		$var$ $lastTime$ = $new$ $Date$().$getTime$();
    		
    		$function$ $movedMouse$($event$)
    		{
    			$console$[ &$quot$;$error$&$quot$; ]( &$quot$;$MouseMove$ [&$quot$; + ( $new$ $Date$().$getTime$() - $lastTime$ ) + &$quot$;]: &$quot$; + $event$.$pageX$ + &$quot$;, &$quot$; + $event$.$pageY$ );
    		}
    		
    		$document$.$addEventListener$( &$quot$;$mousemove$&$quot$;, $movedMouse$, $true$ );
    		
    		$if$ ($window$.$PalmSystem$)
    		{
    			$window$.$PalmSystem$.$stageReady$();
    			$window$.$PalmSystem$.$enableFullScreenMode$($true$);
    		}
    	&$lt$;/$script$&$gt$;
    &$lt$;/$body$&$gt$;
    &$lt$;/$html$&$gt$;
    EDIT: Just for clarification:

    If I instead use Mojo (including the mojo.jsjsjs $script$) $and$ $put$ $that$ $script$ $code$ $above$ $into$ $my$ $stage$ $assistant$, $it$ $works$ $perfectly$ $and$ $mouse$ $events$ $are$ $sent$ $immeadiately$! $Anyone$ $know$ $why$?
    Last edited by 6tr6tr; 06/16/2011 at 04:57 PM.
  2. #2  
    I couldn't say for sure what is going on, but for some clues I would try looking at Gesture.jsjsjs $in$ $the$ $Enyo$ $source$.
    Last edited by megaman821; 06/16/2011 at 08:35 PM.
  3.    #3  
    Quote Originally Posted by megaman821 View Post
    I could say for sure what is going on, but for some clues I would try looking at Gesture.jsjsjs $in$ $the$ $Enyo$ $source$.
    Do you mean you couldn't say? (not being a jerk, just not sure which you meant)

    I did some looking in there but I didn't see anything that would indicate why. I think it's because in the source code for webos (the proprietary c/c++ stuff) they must be changing how the code works with the device when mojo is loaded (maybe switched to run on GPU?).
  4. #4  
    TheMarco (I believe) has had pretty good success running pure HTML webapps on webOS (I couldn't say for sure what versions). I'm not sure if that's his screen name on here, but that is it on the HP developer forums.
  5. #5  
    Quote Originally Posted by 6tr6tr View Post
    Do you mean you couldn't say? (not being a jerk, just not sure which you meant)

    I did some looking in there but I didn't see anything that would indicate why. I think it's because in the source code for webos (the proprietary c/c++ stuff) they must be changing how the code works with the device when mojo is loaded (maybe switched to run on GPU?).
    Maybe, but I don't think it is likely. Does calling event.stopPropagation() in movedMouse() speed things up at all?
  6.    #6  
    Quote Originally Posted by megaman821 View Post
    Maybe, but I don't think it is likely. Does calling event.stopPropagation() in movedMouse() speed things up at all?
    Unfortunately, no. It makes no difference.
  7. #7  
    You shouldn't be using mouse events because WebOS devices don't have a mouse. Try using touchstart, touchend and touchmove and you'll see huge improvements
    My shiny new TouchPad apps: Scientific RPN Calculator HD - Screamager HD
  8.    #8  
    Quote Originally Posted by TheMarco View Post
    You shouldn't be using mouse events because WebOS devices don't have a mouse. Try using touchstart, touchend and touchmove and you'll see huge improvements
    Thanks but when I listen for those events, nothing happens! The method's never called.

    I did:

    Code:
    document.addEventListener( "touchmove", movedMouse, true );
    I also tried "touchstart" and "touchend". Is my code wrong?

    EDIT: Also, when I look into WebOS' code, I see them use a lot of mousedown/move events but no touchstart events. And mousedown/mousemove works perfectly for me as long as it's a mojo app.
    Last edited by 6tr6tr; 06/17/2011 at 12:55 PM.
  9. #9  
    For starters, the call should be like this:

    if (window.PalmSystem)
    {
    window.PalmSystem.stageReady();
    window.PalmSystem.enableFullScreenMode(true);
    }

    document.addEventListener( "mousemove", movedMouse, true );

    Second, native JavaScript will run faster than Mojo or Enyo calls. Granted, you won't notice the difference, but Mojo is just a wrapper between you and the native browser, it does not have special access to the hardware.

    I am not sure why you are experiencing slower response, maybe it has to do with some other function that you are not calling in the Mojo code.

    And I am speaking from personal experience here. Audiophile is written entirely in JavaScript and JQuery, no Mojo involved.
  10.    #10  
    Quote Originally Posted by nyuepik View Post
    For starters, the call should be like this:

    if (window.PalmSystem)
    {
    window.PalmSystem.stageReady();
    window.PalmSystem.enableFullScreenMode(true);
    }

    document.addEventListener( "mousemove", movedMouse, true );

    Second, native JavaScript will run faster than Mojo or Enyo calls. Granted, you won't notice the difference, but Mojo is just a wrapper between you and the native browser, it does not have special access to the hardware.

    I am not sure why you are experiencing slower response, maybe it has to do with some other function that you are not calling in the Mojo code.

    And I am speaking from personal experience here. Audiophile is written entirely in JavaScript and JQuery, no Mojo involved.
    It's weird. I tried your change and it's still super slow! I tested this on both a Pre- and a Pre2. Both are slow.

    Can you try out my code and tell me what happens?

    EDIT: When I use the same exact code (and never call Mojo) but simply add the mojo.jsjsjs $file$ $and$ $the$ $sources$.$json$ $file$, $my$ $code$ $suddenly$ $runs$ $super$ $fast$. $Despite$ $still$ $using$ $only$ $javascript$ $calls$!
    Last edited by 6tr6tr; 06/17/2011 at 02:32 PM.
  11. #11  
    I wonder if it has something to do with sending it to console?

    Maybe try something like (you may have to tweak it slightly since I don't have my phone available to test at the moment). I will try your code when I get home.

    <div id="test">
    </div>

    <script>
    var testObj = document.getElementById("test");
    var check = 0;

    function movedMouse(event)
    {
    testObj.innerHTML = Number(check++).toString();
    }
    </script>
  12.    #12  
    Quote Originally Posted by nyuepik View Post
    I wonder if it has something to do with sending it to console?

    Maybe try something like (you may have to tweak it slightly since I don't have my phone available to test at the moment). I will try your code when I get home.

    <div id="test">
    </div>

    <script>
    var testObj = document.getElementById("test");
    var check = 0;

    function movedMouse(event)
    {
    testObj.innerHTML = Number(check++).toString();
    }
    </script>
    I tested it without any console printings and it was still slow. Please let me know how it tests on an actual Pre2/Pre-/+ and not in an emulator. Thanks!
  13. #13  
    No difference. The console output is laggy, but its the same for either method, and the console is always laggy.

    Have you had problems with it in an actual app?
  14.    #14  
    Quote Originally Posted by nyuepik View Post
    No difference. The console output is laggy, but its the same for either method, and the console is always laggy.

    Have you had problems with it in an actual app?
    Well, yes and no. If the app I make has no mojo (i.e. no sources.json and no mojo.jsjsjs $script$ $linked$ $in$ $index$.$html$) $then$ $it$ $lags$. $If$ $I$ $have$ $sources$.$json$ $and$ $the$ $mojo$.$js$ $script$ $but$ $NEVER$ $call$ $a$ $single$ $Mojo$ $function$ (.$i$.$e$ $use$ $exactly$ $the$ $same$ $code$), $then$ $it$'$s$ $super$ $fast$!
  15. #15  
    Are you changing orientation at all?

    There is a strange quirk in the way PalmSystem works in that it tries to call Mojo every time you change orientation.

    You can deal with it as follows:

    window.Mojo.screenOrientationChanged = function() {};

    Also, probably worth throwing in a
    var Mojo = new Object();
    too just to cover yourself.
  16.    #16  
    Quote Originally Posted by nyuepik View Post
    Are you changing orientation at all?

    There is a strange quirk in the way PalmSystem works in that it tries to call Mojo every time you change orientation.

    You can deal with it as follows:

    window.Mojo.screenOrientationChanged = function() {};

    Also, probably worth throwing in a
    var Mojo = new Object();
    too just to cover yourself.
    I'll try that but you've seen the code as laggy as well. Since you do use non-mojo code, I'm wondering have you ever done a non-mojo app that's also non-hybrid? I wonder if making it hybrid does the same thing as making it mojo or not.
  17. #17  
    The console log is laggy. That is very different from the app being laggy. I have never experienced the app being laggy, even when working in non-hybrid mode.
  18.    #18  
    Quote Originally Posted by nyuepik View Post
    The console log is laggy. That is very different from the app being laggy. I have never experienced the app being laggy, even when working in non-hybrid mode.
    in my original code, i'm not using console and it's still laggy. I'll post some code to show this in a few hours and you can tell me if it still lags for you. BTW, thank you so much for taking the time to help me! You're very generous and kind!
  19.    #19  
    I think I might have figured out the issue (but not the underlying cause):

    If I do more than one DOM alteration in the event handler (for example, a removeChild AND an appendChild) then there's a lag on BOTH! If, however, I ONLY do a removeChild, then there's no lag!!

    The odd thing is, if I simply include mojo, then I can do BOTH calls to manipulate the DOM with zero lag!
  20. #20  
    Try separating out each DOM alteration into a separate Timeout that is set to trigger 1 ms later. There is an issue with the webkit implementation that 2.1 uses that causes DOM alterations to batch. Maybe when you include Mojo it is separating the calls behind the scene.
Page 1 of 2 12 LastLast

Posting Permissions