camera in CroquetEvent?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

camera in CroquetEvent?

Howard Stearns
Somewhere between Croquet-Harness-das.84 and Croquet-Harness-bgf.100,  
CroquetEvent grew a 'camera' instance variable.
It looks like this is set by CroquetHarness>>mouseDown:, mouseMove:,  
and mouseUp:, but never actually read by anyone.

This is causing me problems that I didn't have before: My controller  
indirectly holds on to my harness. Since harness has an event, and  
event now has a camera, I now sometimes run into cross-island  
references when I try to take a snapshot (e.g., for sync'ing).

Am I being evil?



Reply | Threaded
Open this post in threaded view
|

Re: camera in CroquetEvent?

Andreas.Raab
Hi Howard -

There must be something else wrong. Both event and camera are owned by
the harness (created in #initialize and #bounds: respectively) and not
by any particular island, so creating a reference from one to the other
doesn't violate any island discipline and shouldn't cause problems.

Cheers,
   - Andreas

Howard Stearns wrote:

> Somewhere between Croquet-Harness-das.84 and Croquet-Harness-bgf.100,
> CroquetEvent grew a 'camera' instance variable.
> It looks like this is set by CroquetHarness>>mouseDown:, mouseMove:, and
> mouseUp:, but never actually read by anyone.
>
> This is causing me problems that I didn't have before: My controller
> indirectly holds on to my harness. Since harness has an event, and event
> now has a camera, I now sometimes run into cross-island references when
> I try to take a snapshot (e.g., for sync'ing).
>
> Am I being evil?
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: camera in CroquetEvent?

Howard Stearns
In reply to this post by Howard Stearns
Thanks, Andreas.

What's the definition of "island discipline?"  I think it has  
something to do with no island (including the Island default) holding  
on to any long-lived references to something in another island.
   - But there are exceptions that are allowed, such as classes.
   - And I'm not sure what the limitations are on transiently held  
references. Empirically, I know that the execution of a future  
message from the Island default to another island can pass  something  
on to the Island default (e.g., a CroquetEvent), but I imagine that  
the island better not store that reference such that it's still  
around when the island tries to sync.

I don't know how to look at it right. Here's my thinking, but it  
would lead me to believe that snapshots would reliably fail all the  
time, which they don't:
    The snapshot trace (below) shows that when the event holds the  
camera, then the Island default (outside) has a reference to the  
camera. OK, that's fair.  And it shows that the island being sync'ed  
has created a TFarRef to the camera.  Thus the island (inside) and  
the outside both reference the camera. Bad.  I think the reason the  
island makes a TFarRef to the camera is that event handlers like  
#pointerDown: pass the CroquetEvent, which is passByClone:, and so it  
tries to pass the camera in turn. Since the camera is passByProxy:,  
it creates a TFarRef.



Outside references:

root: Smalltalk specialObjects (Array)
39: Array
16: Semaphore
firstLink: Process
???: MethodContext
???: MethodContext
???: MethodContext
???: BlockContext
home: MethodContext
2: MessageSend
receiver: WisconsinController
clipboard: CroquetClipboard
harness: WisconsinHarness
event: CroquetEvent
camera: TCamera

root: Smalltalk specialObjects (Array)
39: Array
16: Semaphore
firstLink: Process
???: MethodContext
???: MethodContext
???: MethodContext
???: BlockContext
home: MethodContext
2: MessageSend
receiver: WisconsinController
clipboard: CroquetClipboard
harness: WisconsinHarness
event: CroquetEvent
camera: TCamera
objectID: TObjectID

Inside references:

root: a TFarRef(a TCamera) (TFarRef)
myValue: TCamera

root: a TFarRef(a TGroup) (TFarRef)
myIsland: TIsland
nameMap: Dictionary
array: Array
656: Association
key: TObjectID


On Jul 19, 2006, at 11:29 PM, Andreas Raab wrote:

> Hi Howard -
>
> There must be something else wrong. Both event and camera are owned  
> by the harness (created in #initialize and #bounds: respectively)  
> and not by any particular island, so creating a reference from one  
> to the other doesn't violate any island discipline and shouldn't  
> cause problems.
>
> Cheers,
>   - Andreas
>
> Howard Stearns wrote:
>> Somewhere between Croquet-Harness-das.84 and Croquet-Harness-bgf.
>> 100, CroquetEvent grew a 'camera' instance variable.
>> It looks like this is set by CroquetHarness>>mouseDown:,  
>> mouseMove:, and mouseUp:, but never actually read by anyone.
>> This is causing me problems that I didn't have before: My  
>> controller indirectly holds on to my harness. Since harness has an  
>> event, and event now has a camera, I now sometimes run into cross-
>> island references when I try to take a snapshot (e.g., for sync'ing).
>> Am I being evil?


Reply | Threaded
Open this post in threaded view
|

Re: camera in CroquetEvent?

Andreas.Raab
In reply to this post by Howard Stearns
Howard Stearns wrote:
> What's the definition of "island discipline?"  I think it has something
> to do with no island (including the Island default) holding on to any
> long-lived references to something in another island.

Really only that an object mustn't refer directly to objects in other
islands.

>   - But there are exceptions that are allowed, such as classes.

Unfortunately, yes. Couldn't make it work for the time being without
those :-(((

>   - And I'm not sure what the limitations are on transiently held
> references. Empirically, I know that the execution of a future message
> from the Island default to another island can pass  something on to the
> Island default (e.g., a CroquetEvent), but I imagine that the island
> better not store that reference such that it's still around when the
> island tries to sync.

With proper future messaging this isn't a problem. A CroquetEvent for
example gets copied when it's passed into the island. So storing isn't a
problem at all. Generally, all objects get copied when you pass them
into an island unless you pass a reference to an object inside that
island. The only exceptions are classes (as you noted above).

> I don't know how to look at it right. Here's my thinking, but it would
> lead me to believe that snapshots would reliably fail all the time,
> which they don't:
>    The snapshot trace (below) shows that when the event holds the
> camera, then the Island default (outside) has a reference to the camera.
> OK, that's fair.  And it shows that the island being sync'ed has created
> a TFarRef to the camera.  Thus the island (inside) and the outside both
> reference the camera. Bad.  I think the reason the island makes a
> TFarRef to the camera is that event handlers like #pointerDown: pass the
> CroquetEvent, which is passByClone:, and so it tries to pass the camera
> in turn. Since the camera is passByProxy:, it creates a TFarRef.

Yes, but this wouldn't apply in the case of a future message. Your
analysis makes sense in the situation that the event is used in a
synchronous send; but I'm not sure where this would happen. Here is
something to try: Change TCamera class>>howToPassAsArgument to something
that will raise an error when you try to execute it (say #passByFoo:) to
see where exactly that reference is created.

Cheers,
   - Andreas

Reply | Threaded
Open this post in threaded view
|

Re: camera in CroquetEvent?

Howard Stearns
In reply to this post by Howard Stearns
Andreas, you're right about the TFarRef happening outside a future  
message. It happens in:

TChattyAvatarReplica>>prointerLeave: evt
        super pointerLeave: evt.
        self root signal: #hideID with: evt with: nickname.

In this case, we can change the above and TChattyAvatarUser>>hideID:  
to just pass the evt userID.
Or we can change it to pass a copy of the event, as is done by:

TAvatarUserMenu>>doBlueButtonUp: event
        | eventCopy |
        eventCopy := event copy.
        eventCopy selection: event selection copy.
        eventCopy selection target future signal: #blueButtonUp with:  
eventCopy.

But I'm not clear on the philosophy by which to decide what the right  
path is. (I guess it would be up to Tony.)  Naively, it seems weird  
to have events be #passByClone:, only to have to have to make copies  
whenever we want to actually pass one.


On Jul 22, 2006, at 10:07 PM, Andreas Raab wrote:

> Howard Stearns wrote:
>> What's the definition of "island discipline?"  I think it has  
>> something to do with no island (including the Island default)  
>> holding on to any long-lived references to something in another  
>> island.
>
> Really only that an object mustn't refer directly to objects in  
> other islands.
>
>>   - But there are exceptions that are allowed, such as classes.
>
> Unfortunately, yes. Couldn't make it work for the time being  
> without those :-(((
>
>>   - And I'm not sure what the limitations are on transiently held  
>> references. Empirically, I know that the execution of a future  
>> message from the Island default to another island can pass  
>> something on to the Island default (e.g., a CroquetEvent), but I  
>> imagine that the island better not store that reference such that  
>> it's still around when the island tries to sync.
>
> With proper future messaging this isn't a problem. A CroquetEvent  
> for example gets copied when it's passed into the island. So  
> storing isn't a problem at all. Generally, all objects get copied  
> when you pass them into an island unless you pass a reference to an  
> object inside that island. The only exceptions are classes (as you  
> noted above).
>
>> I don't know how to look at it right. Here's my thinking, but it  
>> would lead me to believe that snapshots would reliably fail all  
>> the time, which they don't:
>>    The snapshot trace (below) shows that when the event holds the  
>> camera, then the Island default (outside) has a reference to the  
>> camera. OK, that's fair.  And it shows that the island being  
>> sync'ed has created a TFarRef to the camera.  Thus the island  
>> (inside) and the outside both reference the camera. Bad.  I think  
>> the reason the island makes a TFarRef to the camera is that event  
>> handlers like #pointerDown: pass the CroquetEvent, which is  
>> passByClone:, and so it tries to pass the camera in turn. Since  
>> the camera is passByProxy:, it creates a TFarRef.
>
> Yes, but this wouldn't apply in the case of a future message. Your  
> analysis makes sense in the situation that the event is used in a  
> synchronous send; but I'm not sure where this would happen. Here is  
> something to try: Change TCamera class>>howToPassAsArgument to  
> something that will raise an error when you try to execute it (say  
> #passByFoo:) to see where exactly that reference is created.
>
> Cheers,
>   - Andreas
>