x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Client RPC handles earlier than BeginPlay[updated]

I got strange behavior in my class. I spawn actor instance of my class on server by calling ServerRPC function from client. Server spawns actor with client as owner. Next, Server calls ClientRPC on spawned actor (need to say that actor have bReplicates = true; and bAlwaysRelevant = true; in constructor).

So actor is replicated to client and there is called ClientRPC_Implementation. First time all works fine, but that's all. Second and next actors wont properly execute ClientRPC (because there is condition with IsValid() check, that checks property, which would be set in BeginPlay).

I attached VS to game instance and found that for some reasons ClientRPC on client-side is called earlier than BeginPlay(on 2nd+ spawned actor), but first spawned actor have done work properly.

Anybody can reproduce this behavior? Or maybe I missed something then give me right point to see. Thanks in advance

UPDATE: Okay, as nobody answers I made little sample(in 4.11.p3 already). That's log which I receive:

 LogTemp:Warning: Within ADerivedOneActor::BeginPlay()
 LogTemp:Warning: Within ADerivedOneActor::ClientRPC_Implementation()
 LogTemp:Warning: Within ADerivedTwoActor::BeginPlay()
 LogTemp:Warning: Within ADerivedTwoActor::ClientRPC_Implementation()
 LogTemp:Warning: Within ADerivedOneActor::ClientRPC_Implementation()
 LogTemp:Warning: Within ADerivedOneActor::BeginPlay()
 LogTemp:Warning: Within ADerivedTwoActor::ClientRPC_Implementation()
 LogTemp:Warning: Within ADerivedTwoActor::BeginPlay()
 LogTemp:Warning: Within ADerivedOneActor::ClientRPC_Implementation()
 LogTemp:Warning: Within ADerivedOneActor::BeginPlay()
 LogTemp:Warning: Within ADerivedTwoActor::ClientRPC_Implementation()
 LogTemp:Warning: Within ADerivedTwoActor::BeginPlay()


That log I received on both: client and server instance(here in PIE, in my other project I received this behavior in standalone application). As you can see from 5th line, Client_RPC began occur earlier than BeginPlay(be care here are 2 different actors that writes to log)

Here's source files for project. If someone says how to upload whole project that it will take less than 5 MB then I can upload whole project.

It seems for me like a bug. Now can anybody give me some kind of answer, is it right flow of spawning and replicating actor or not?

Product Version: UE 4.11 Preview
Tags:
source.zip (6.6 kB)
more ▼

asked Jan 31 '16 at 03:26 PM in Bug Reports

avatar image

alkohol
231 12 5 16

avatar image alkohol Jan 31 '16 at 03:59 PM

I have 2 classes that are working the way above, and within 1 game session first actor of each class is executed properly and next instances not. If I disconnect from server(with changing map to main menu) and connect again, then again: first try - success, next tries: fail.

avatar image Doug E ♦♦ STAFF Feb 02 '16 at 02:17 PM

Hey alkohol-

If you zip the full sample project you should be able to upload the zip file to dropbox, then you would just need to send the link to download the project directly. You can post the link here or send me a PM on the forums for privacy.

Cheers

Doug Wilson

avatar image alkohol Feb 02 '16 at 02:25 PM

Can I drop out Binaries and Internediate folders from archive or it will be not open?

avatar image Doug E ♦♦ STAFF Feb 02 '16 at 03:47 PM

Binaries, Intermediate, and Saved folders should all be safe to remove before zipping to reduce compression size, yes.

avatar image alkohol Feb 04 '16 at 06:16 PM

Sorry for late answer, Doug. Here is the project.

avatar image Doug E ♦♦ STAFF Feb 10 '16 at 05:26 PM

Hey alkohol-

We are still investigating the project you sent to try to understand why the ClientRPC() function is printing before the BeginPlay() function. I will update you here when there is more information.

Cheers

Doug Wilson

avatar image alkohol Feb 11 '16 at 02:14 AM

Hi Doug!

Updated link, it will expire after 2 days, so if it's needed I can reupload it again.

and again...
Thanks, for supporting :)

(comments are locked)
10|2000 characters needed characters left

3 answers: sort voted first

Hey alkohol-

After further investigation I have entered a bug report (UE-26811) to investigate why the ClientRPC function is being called before BeginPlay.

Cheers

Doug Wilson

more ▼

answered Feb 11 '16 at 06:00 PM

avatar image alkohol Feb 11 '16 at 11:21 PM

Thank you, Doug.

avatar image alleysark Aug 01 '18 at 07:50 AM

It's pretty old thread, but is there any update for this issue?

https://issues.unrealengine.com/issue/UE-26811 says that the problem cannot be reproduced. But I also suffer this type of problem now on version 4.19 (with very small customization)

The situation that I saw is little different with yours. The Multicast RPC was handled after the Actor's BeginPlay but before UActorComponent's BeginPlays.

I also spawn the actor at runtime, and Multicast RPC is called from dedicated server after player joined.

If there are documents about Actor and Components lifecycle with replication behaviors, please let me know.

Thanks!

(comments are locked)
10|2000 characters needed characters left

So I was having a similar problem, and I think it's a bug in DataChannel.cpp. UActorChannel::ProcessBunch will spawn the actor if needed, dispatch all available bunches, and then call BeginPlay at the very end of the function via PostNetInit.

It should really be calling PostNetInit immediately after any Initial bunches have been dispatched and before any further bunches are processed, it also looks like it's passing in RepFlags.bNetInitial = true; for all bunches in that loop, I'm not sure if that's okay or not?

I tried moving the init call to inside the loop at the end, but that assumes that there's always exactly one initial replication bunch.

Edit: This was a bit of a necropost so I created a new question on UDN.

more ▼

answered Aug 17 '18 at 07:02 PM

avatar image

discodonut
16 3

(comments are locked)
10|2000 characters needed characters left

I am experiencing the exact same on my project. 1.) I spawn an actor on the server in a blueprint. 2.) Immediately after, i call a multicast RPC from blueprint. The RPC itself is implemented in C++.

First actor: Actor gets replicated, BeginPlay executes, RPC executes.

Second actor: Actor gets replicated, RPC executes, crash because RPC uses data initialized in BeginEvent.

Time between spawning of actors doesn't matters. Happens 100% of tries.

I worked around it by having a BeginPlayCalled property, which is set to true at the end of BeginPlay and all client RPC's check for this variable and if false, add the RPC to a event buffer and return out. The event buffer is executed at the end of BeginPlay. This fixes it reliably, but is quite some extra work.

I need some time to isolate code to have a project to replicate this behavior. Just a heads up that thiis problem is still existing as of 4.21.1 and "quick" workaround to get your project to work in multiplayer.

more ▼

answered Dec 09 '18 at 02:51 PM

avatar image

CatBit Thorium
1 1 2

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question