Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Resolved Ads cause EmbeddableUI to not show on first load

Client Developer
Joined
Oct 12, 2015
Messages
3,781
When an ad plays, it causes the EmbeddableUI to null whilst the instance is technically running, meaning the bot crashes.

Sorry if that's shitty English 8)

Using following:
Code:
setEmbeddableUI(() -> {
            Future<InputStream> inputStream = getPlatform().invokeLater(() -> Resources.getAsStream("com/pBots/framework/userinterface/pInterface.fxml"));
            FXMLLoader loader = new FXMLLoader();
            loader.setController(uiController = new pInterfaceController(this));
            return ui = loader.load(inputStream.get());
        });
 
Χ Ξ Σ
Joined
Apr 15, 2016
Messages
379
Yes please I'm getting flooded with exception notifications :( :eek:

Also can you just get rid of those client ads while we're at it? :/
 
Client Developer
Joined
Oct 12, 2015
Messages
3,781
Yes please I'm getting flooded with exception notifications :( :eek:

Also can you just get rid of those client ads while we're at it? :/

The client ads make sense, but I cannot think of any reason why they should be there in SDK mode.
 
Χ Ξ Σ
Joined
Apr 15, 2016
Messages
379
The client ads make sense, but I cannot think of any reason why they should be there in SDK mode.
I don't know. But I'll not derail the thread further :p

Are we supposed to delay loading the UI and starting the bot tasks now? As in is this our fault or the client? (UI exceptions because of these ads).
I feel like I saw a snippet somewhere on here that had some thing to wait for the UI to be loaded before proceding in one the UI example bots.
 
Client Developer
Joined
Oct 12, 2015
Messages
3,781
I don't know. But I'll not derail the thread further :p

Are we supposed to delay loading the UI and starting the bot tasks now? As in is this our fault or the client? (UI exceptions because of these ads).
I feel like I saw a snippet somewhere on here that had some thing to wait for the UI to be loaded before proceding in one the UI example bots.

Really I feel like (if it's possible) the instances should be delayed until the ad has finished.
 
Joined
Dec 10, 2014
Messages
3,332
Really I feel like (if it's possible) the instances should be delayed until the ad has finished.
I also feel like this should be the case. It seems like the call to botInterfaceProperty() happens after the ad, but onStart(String...) happens during the ad.
 
Mod Automation
Joined
Jul 26, 2013
Messages
3,053
This is not a client bug. This is an issue in your bot logic.

The EmbeddableUI framework is completely asynchronous of your bot logic. Your bot logic should not depend on the botInterfaceProperty having been invoked. If it absolutely must then you will need to make your bot wait, i.e. using a looped Execution.delay, until it is loaded or invoke it yourself. To summarize, you cannot ever assume that the botInterfaceProperty method has been invoked for you.

The reason that this issue did not come up before was because in the race condition that has always existed between the JFX platform and bot platform, the JFX Platform consistently won so the UI was initialized before the bot's onStart method was invoked. However, now with the introduction of ads we start the bot in the background, essentially giving it a headstart on the JFX platform. It simply revealed an existing issue with your code.

tl;dr fix ur code
 
Joined
Dec 10, 2014
Messages
3,332
This is not a client bug. This is an issue in your bot logic.

The EmbeddableUI framework is completely asynchronous of your bot logic. Your bot logic should not depend on the botInterfaceProperty having been invoked. If it absolutely must then you will need to make your bot wait, i.e. using a looped Execution.delay, until it is loaded or invoke it yourself. To summarize, you cannot ever assume that the botInterfaceProperty method has been invoked for you.

The reason that this issue did not come up before was because in the race condition that has always existed between the JFX platform and bot platform, the JFX Platform consistently won so the UI was initialized before the bot's onStart method was invoked. However, now with the introduction of ads we start the bot in the background, essentially giving it a headstart on the JFX platform. It simply revealed an existing issue with your code.

tl;dr fix ur code
Tfw it also breaks Development Toolkit.
 
Mod Automation
Joined
Jul 26, 2013
Messages
3,053
Tfw it also breaks Development Toolkit.
Latest commit: Ensures that EmbeddableUI methods get invoked on the bot platform, so as to provide Bot Authors with a consistent experience even though they should be handling the possibility that it isn't invoked from the bot platform.

The issue that DevKit had is distinct from the OP's issue. OP's issue was OP's fault, but you bringing up DevKit made me realize another potential issue as outlined above. Regardless, we should be all good once the next build goes out.
 
Top