Null reference error in UserList::initDataProvider()

Everything about the SmartFoxBits UI Components for SmartFoxServer 2X. Post your questions, suggestions and bug reports.

Moderators: Lapo, Bax

Farbs
Posts: 5
Joined: 06 Apr 2011, 02:44
Contact:

Null reference error in UserList::initDataProvider()

Postby Farbs » 07 Apr 2011, 06:28

Hi,

The following error occurs sometimes, but not always, when we remove a UserList from the stage at the same time as a user leaves the room. Unfortunately we don't have source so I can't look up any of the entries in the stack.

Code: Select all

TypeError: Error #1009: Cannot access a property or method of a null object reference.
   at com.smartfoxserver.smartfoxbits.bits::UserList/initDataProvider()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer2X/SmartFoxBits/Flex/Base Pack/source/src/com/smartfoxserver/smartfoxbits/bits/UserList.as:1161]
   at com.smartfoxserver.smartfoxbits.bits::UserList/onUserExitRoom()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer2X/SmartFoxBits/Flex/Base Pack/source/src/com/smartfoxserver/smartfoxbits/bits/UserList.as:1434]
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at com.smartfoxserver.v2.controllers::SystemController/fnUserExitRoom()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/controllers/SystemController.as:552]
   at com.smartfoxserver.v2.controllers::SystemController/handleMessage()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/controllers/SystemController.as:123]
   at com.smartfoxserver.v2.core::SFSProtocolCodec/dispatchRequest()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/core/SFSProtocolCodec.as:150]
   at com.smartfoxserver.v2.core::SFSProtocolCodec/onPacketRead()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/core/SFSProtocolCodec.as:54]
   at com.smartfoxserver.v2.core::SFSIOHandler/handlePacketData()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/core/SFSIOHandler.as:231]
   at com.smartfoxserver.v2.core::SFSIOHandler/onDataRead()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/core/SFSIOHandler.as:90]
   at com.smartfoxserver.v2.bitswarm::BitSwarmClient/onSocketData()[/Users/Lapo/Documents/Flex Builder 3/SFS2X_AS3_API/src/com/smartfoxserver/v2/bitswarm/BitSwarmClient.as:404]

Any ideas?
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 07 Apr 2011, 08:36

Code: Select all

TypeError: Error #1009: Cannot access a property or method of a null object reference.
   at com.smartfoxserver.smartfoxbits.bits::UserList/initDataProvider()[/Users/Paolo/gotoAndPlay/gotoAndPlay/SmartFoxServer2X/SmartFoxBits/Flex/Base Pack/source/src/com/smartfoxserver/smartfoxbits/bits/UserList.as:1161]

This is what line 1161 does:

Code: Select all

var userList:Object = smartFox.lastJoinedRoom.userList

I suppose lastJoinedRoom is null, because the user left the room.
What I don't understand why it just happens sometimes.
Maybe you could check the sequence of events and calls to your methods, to understand in which cases this happens.
Paolo Bax
The SmartFoxServer Team
Farbs
Posts: 5
Joined: 06 Apr 2011, 02:44
Contact:

Postby Farbs » 08 Apr 2011, 01:43

Cheers.

I don't seem to be able to get it to happen at all today, but on previous days it would happen sometimes, but not others, under the same circumstances. My guess is it's an order of execution problem between the display updating and the room departure message being received from the server.

I observed this problem towards the end of the day, by which time eclipse had hogged most of my system resources. I'll try running a few complete rebuilds to see if I can recreate the scenario and reproduce the bug.

Would it be possible for you to check for null on this line? I'd like to get this fixed regardless of what the cause may be.
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 08 Apr 2011, 08:04

It is not that easy to add a simple null check here, because it could interfere with the following instructions.
The strange is that usually when you leave a room, you join another one. Is this not the case of your app?
Paolo Bax
The SmartFoxServer Team
Farbs
Posts: 5
Joined: 06 Apr 2011, 02:44
Contact:

Postby Farbs » 12 Apr 2011, 03:14

Cheers. We currently do the following:

(1) Send an extension request from the client to the server. A request handler on the server hears this and adds the user to room B.
(2) Send a leave room request from the client to leave room A.

Is it possible that the response to leaving room A in (2) is sometimes received by the client before the response to leaving the room in (1)?

I'll try leaving the first room before joining the second one to see if that helps.
Farbs
Posts: 5
Joined: 06 Apr 2011, 02:44
Contact:

Postby Farbs » 12 Apr 2011, 03:24

Oh, this is interesting. By swapping steps (1) and (2) above I still saw the error, but it occurred ~80% of the time whereas before it occurred ~20% of the time.
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 12 Apr 2011, 21:58

Not sure why this happens occasionally. Anyway it seems to be related to a user not being inside a room.
We managed to fix this and it will be available in the next release of SmartFoxBits which is due... in a few minutes! 8)
Paolo Bax
The SmartFoxServer Team
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 12 Apr 2011, 22:06

Please check this post.
Paolo Bax
The SmartFoxServer Team
Farbs
Posts: 5
Joined: 06 Apr 2011, 02:44
Contact:

Postby Farbs » 12 Apr 2011, 23:26

Thanks bax, this is much appreciated!

Return to “SmartFoxBits for SFS 2X”

Who is online

Users browsing this forum: No registered users and 3 guests