Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 418719

Summary: Client error: TypeError while press key quickly
Product: [RT] RAP Reporter: Jacob He <lord_hzq>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: ivan, lord_hzq, rherrad, rsternberg, tbuschto
Version: 2.1   
Target Milestone: 2.2 M3   
Hardware: PC   
OS: Windows 7   
Whiteboard: sr212
Attachments:
Description Flags
Demo project to reproduce the bug.
none
target for bug 418719 validation
none
error stii lexit for bug 418719
none
bug_418719 still occur with continous click on web page none

Description Jacob He CLA 2013-10-04 19:38:15 EDT
Created attachment 236134 [details]
Demo project to reproduce the bug.

On RAP 2.1 application, I pressed keys quickly on page and "client error" occurred.

In FF, error message is: TypeError: ObjectManager.getEntry(...) is undefined
In IE, error message is: TypeError: Unable to get value of the property 'handler': object is null or undefined

Stack trace shows the error occurs at rap-client.js line 71046. The method is rwt.remote.RemoteObjectFactory._initRemoteObject.

Code is:
var handler = ObjectManager.getEntry( id ).handler;

The base idea of my application is:
1. use RWT.ACTIVE_KEYS to accept some shortcut key strike from web page;
2. the key strike will signal a back end thread to run some business logic;
3. the back end thread will update widgets on web page, like deleting old widgets, creating new widgets, updating exist widgets, etc.

The attachment is a prototype project for such idea. The entry point of it is "/demo". After opening a new editor, just press one of following keys quickly enough, the client error will occur always. It has been tried on RAP 2.1 and 2.1.1.

Keys: "ENTER", "BREAK", "PAGE_DOWN", "PAGE_UP", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "SHIFT+F1", "SHIFT+F2", "SHIFT+F3", "SHIFT+F4", "SHIFT+F5", "SHIFT+F6", "SHIFT+F7", "SHIFT+F8", "SHIFT+F9", "SHIFT+F10", "SHIFT+F11", "SHIFT+F12"
Comment 1 Tim Buschtoens CLA 2013-10-07 08:55:38 EDT
In BasicText.js the _applyFocused method is called (newValue == false) on the Text control that is about to be disposed (has no parent anymore) when the new Text control gains the focus and tries to render the selection. The selection should probably only be rendred if the widget is focused, not blurred.

    _applyFocused : function( newValue, oldValue ) {
      this.base( arguments, newValue, oldValue );
      if( !rwt.widgets.util.FocusHandler.mouseFocus ) {
        this._renderSelection();
      }
    },
Comment 2 Jacob He CLA 2013-10-07 09:38:53 EDT
The bug affects not only Text widget, but also other widgets such as Button, Combo, List, etc.
Comment 3 Jacob He CLA 2013-10-07 09:42:17 EDT
Is there any around way to make the application work before the bug is fixed?
Comment 4 Tim Buschtoens CLA 2013-10-07 10:41:24 EDT
(In reply to Jacob He from comment #2)
> The bug affects not only Text widget, but also other widgets such as Button,
> Combo, List, etc.

It affects Text widgets that are focused and disposed while any other widget gets focused. I can't think of a workaround right now, but If I'm correct about the issue the bug should be fixed in 2.2M3, 2.1.2, and in nightly builds relatively soon.
Comment 5 Tim Buschtoens CLA 2013-10-09 10:34:56 EDT
Fixed with commit a218ce1dcb2e8c7910b1c1d8f19438f8547eb2a0 in master.

Commit should be possible to apply to 2.1 branch without conflicts after review.
Comment 6 rherrad abk CLA 2013-10-16 06:47:28 EDT
Created attachment 236525 [details]
target for bug 418719 validation
Comment 7 rherrad abk CLA 2013-10-16 06:51:20 EDT
Comment on attachment 236525 [details]
target for bug 418719 validation

I downloaded with the bug fix but it does not work version. validated test with the demo posted by He the error still exist
Comment 8 rherrad abk CLA 2013-10-16 06:52:29 EDT
Created attachment 236526 [details]
error stii lexit for bug 418719
Comment 9 Ivan Furnadjiev CLA 2013-10-16 07:29:40 EDT
Are you using RAP nightly p2 repo - http://download.eclipse.org/rt/rap/nightly/runtime/?
Comment 10 rherrad abk CLA 2013-10-16 08:26:21 EDT
(In reply to Ivan Furnadjiev from comment #9)
> Are you using RAP nightly p2 repo -
> http://download.eclipse.org/rt/rap/nightly/runtime/?

yes I use http://download.eclipse.org/rt/rap/nightly/runtime/? I noticed that to quickly press the page down key example does not crash the application. The bug occurs when i click for 2 or 3 continuous seconds. I attached the logs in the browser file navigator_log.txt
Comment 11 rherrad abk CLA 2013-10-16 08:28:54 EDT
Created attachment 236537 [details]
bug_418719 still occur with continous click on web page
Comment 12 Ivan Furnadjiev CLA 2013-10-16 08:37:52 EDT
OK... I will reopen the bug for further investigation.
Comment 13 Tim Buschtoens CLA 2013-10-17 04:33:47 EDT
Stack trace suggests this is unrelated to the issue I fixed (i.e. there are two bugs in the code that can be triggered the same way.) The issue is KeyEventSupport.checkBufferedEvents - it attempts to send key events for widgets that are already disposed. Fix should be easy, though it would be preferrable to refactor this method completely to take advantage of the new OperationHandler. For 2.1.2 however we will just have to check for disposed widgets.
Comment 14 Ivan Furnadjiev CLA 2013-11-07 05:12:37 EST
Fixed in master with commit 43407ec12d41c7532bb8532e03ca4426fb330d74.
Comment 15 Ralf Sternberg CLA 2014-01-27 07:52:04 EST
The fix is not really obvious but after Ivan's explanations I'm convinced that it's good for 2.1.2.
Comment 16 Ivan Furnadjiev CLA 2014-01-30 03:19:52 EST
Backported commit 43407ec12d41c7532bb8532e03ca4426fb330d74 to 2.1-maintenance branch with change https://git.eclipse.org/r/21255
Comment 17 Ivan Furnadjiev CLA 2014-01-30 06:28:20 EST
Backported commit a218ce1dcb2e8c7910b1c1d8f19438f8547eb2a0 to 2.1-maintenance branch with change https://git.eclipse.org/r/21310