REALGetControlBounds of a MobileControl

Do you call it on the graphics or the control?

double w = 0, h = 0;
REALGetPropValueDouble((REALobject)context, "Width",  &w);
REALGetPropValueDouble((REALobject)context, "Height", &h);

this works here on the context, which is a graphics object for me.

He is embedding and I would imagine he needs the size of the control long before it should paint it self.

So here is the hang when dynamic access is used on the plugin instance to get the left, top, width and height: The plugin uses:

RBInteger top, left, width, height;
REALGetPropValueInteger(instance, "Top", &top);
REALGetPropValueInteger(instance, "Left", &left);
REALGetPropValueInteger(instance, "Width", &width);
REALGetPropValueInteger(instance, "Height", &height);

Date/Time: 2021-02-23 21:00:10.967 -0500
End time: 2021-02-23 21:00:32.695 -0500
OS Version: macOS 11.2.1 (Build 20D74)
Architecture: arm64e
Report Version: 32
Share With Devs: Yes

Data Source: Stackshots
Shared Cache: 42E2F879-5C4F-3E0F-A975-1461DC6198C3 slid base address 0x1a2798000, slide 0x22798000
Shared Cache: 1F0C4D0D-3013-3558-B105-54257AD3329A slid base address 0x7fff20074000, slide 0x74000

Command: Xojo
Path: /Applications/Xojo 2020 Release 2.1/
Identifier: com.xojo.xojo
Version: (
Parent: launchd [1]
PID: 57303
Time Since Fork: 107s

Event: hang
Duration: 21.73s
Duration Sampled: 2.80s (process was unresponsive for 19 seconds before sampling)
Steps: 28 (100ms sampling interval)
Report threshold: 2.5s

Hardware model: MacBookPro17,1
Active cpus: 8

Time Awake Since Boot: 227022s
Time Since Wake: 1540s

Fan speed: 0 rpm

Timeline format: stacks are sorted chronologically
Use -i and -heavy to re-report with count sorting

Heaviest stack for the main thread of the target process:
28 REALLoadObjectMethod(RuntimeObject*, char const*) + 189 (XojoFramework + 2647878) [0x132a52746]
28 ??? [0x1332c7c20]
19 RuntimeObjectIsa + 75 (XojoFramework + 2549836) [0x132a3a84c]

Process: Xojo [57303]
UUID: 12DF997D-5D85-33A1-8C8B-66EFB1FBE52E
Shared Cache: 1F0C4D0D-3013-3558-B105-54257AD3329A slid base address 0x7fff20074000, slide 0x74000
App Version:
Build Version:
Path: /Applications/Xojo 2020 Release 2.1/
Architecture: x86_64 (translated)
Parent: launchd [1]
UID: 501
Footprint: 415.61 MB
Time Since Fork: 107s
Num samples: 28 (1-28)
CPU Time: 1.931s (6.0G cycles, 10.1G instructions, 0.60c/i)
Note: Suspended for 8 samples
Note: Unresponsive for 19 seconds before sampling
Note: 1 idle work queue thread omitted

Thread 0x1f7fc2 DispatchQueue “”(1) 28 samples (1-28) priority 46 (base 46) cpu time 1.931s (6.0G cycles, 10.1G instructions, 0.60c/i)
<thread QoS user interactive (requested user interactive), process unclamped, process received importance donation from WindowServer [544], IO tier 0>
28 REALLoadObjectMethod(RuntimeObject*, char const*) + 189 (XojoFramework + 2647878) [0x132a52746] 1-28
28 ??? [0x1332c7c20] 1-28
5 RuntimeObjectIsa + 75 (XojoFramework + 2549836) [0x132a3a84c] (running) 1-5
1 RuntimeObjectIsa + 80 (XojoFramework + 2549841) [0x132a3a851] (running) 6
2 RuntimeObjectIsa + 75 (XojoFramework + 2549836) [0x132a3a84c] (running) 7-8
8 RuntimeObjectIsa + 78 (XojoFramework + 2549839) [0x132a3a84f] 9-16
*8 ??? (kernel.release.t8101 + 578572) [0xfffffe0007c8d40c] (suspended) 9-16
12 RuntimeObjectIsa + 75 (XojoFramework + 2549836) [0x132a3a84c] (running) 17-28

63769 - REALGetControlBounds fails when used on a MobileControl is said to be fixed. It is not.

Something did change in release 2021r1. Trying to be specific with code in the DrawOffscreen behavior callback.

	Lexing_StateChanged(instance, kBoundsChanged);// called in the offscreen callback

This still crashes on iOS (2021r1)
RBInteger Left;
RBInteger Right;
RBInteger Width;
RBInteger Height;
REALGetPropValueInteger(instance, “Left”, &Left);
REALGetPropValueInteger(instance, “Right”, &Right);
REALGetPropValueInteger(instance, “Width”, &Width);
REALGetPropValueInteger(instance, “Height”, &Height);
XLOG2(“controlBounds: Left (%d) and Right (%d)”, Left, Right);
XLOG2(“controlBounds: Width (%d) and Height (%d)”, Width, Height);

int handle = 5;
CGContextRef context = (CGContextRef)graphics_Handle(rbContext, handle);
XLOG2("got a CGContextRef with value = %x and handle %d", context, handle);

// Figure out where we need to draw
Rect controlBounds;
REALGetControlBounds(instance, &controlBounds);
int32_t x = controlBounds.left;
int32_t y =;
int32_t w = controlBounds.right-controlBounds.left;
int32_t h =;
XLOG2("controlBounds: x (%d) and y (%d)", x, y);// always 0 and 0 for iOS
XLOG2("controlBounds: w (%d) and h (%d)", w, h);// always returns same for iOS

int32_t contextHeight;
REALGetPropValueInt32((REALobject)rbContext, "Height", &contextHeight);

[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithCGContext:context flipped:[[NSGraphicsContext currentContext] isFlipped]]];

// Adjust the co-ordinate system such that the view's origin is where we want
// it to render

NSAffineTransform *transform = [NSAffineTransform transform];
[transform translateXBy:controlBounds.left yBy:contextHeight - controlBounds.bottom];
[transform concat];

// Finally we can do some actual drawing! LSView *view = LexGetHandle(instance);
[view displayRectIgnoringOpacity:[view bounds] inContext:[NSGraphicsContext currentContext]];

[NSGraphicsContext restoreGraphicsState];

This code makes sure (before 2021r1) that the widget snapshot is aligned and “stuck” to the window. But in 2021r1 the widget snapshot is stuck to the left of the window and when the window is dragged from left to right the widget remains at its position (does not move with the window). Dragging (using scrollbar) the window vertically up and down makes the widget snapshot to move up and down.

For iOS, as I said, the REALGetControlBounds does not work is not fixed.

I am happy to send the plugin and two projects in an attachment. The case is closed however.