smartdevicelink / sdl_java_suite

SmartDeviceLink libraries for Android, Java SE, and Java EE
BSD 3-Clause "New" or "Revised" License
187 stars 171 forks source link

Alert RPCs through Alert Manager stop working if the first was not dismissed. #1779

Open mjuarez-ford opened 2 years ago

mjuarez-ford commented 2 years ago

Bug Report

Alerts stop working if the previous notification was not dismissed by the User.

Reproduction Steps
  1. Connect the phone to the TDK
  2. The app must have Alert and background permissions (SYNC)
  3. The app does not need to be open on the HMI, the state of the app is HMI_BACKGROUND
  4. Send an alert with buttons, and do not dismiss it.
  5. Send another Alert (2nd). (this alert is not displayed)
  6. Dismiss the first Alert
  7. Send the 3rd Alert.
  8. The 3rd and consecutive Alert are not sent to the HMI.
Expected Behavior

The user should keep receiving notifications.

Observed Behavior

On the SYNC logs, I verify that on the HMI the Alert RPC is not received. And on the PresentAlertOperation the start() is not executed.

When everything is executing correctly on the Queue class the properties head and tail are always null. But after it breaks it always adds them to the queue.

public void add(Task task, boolean placeAtHead) {
....
  else {
      Queue.Node<Task> taskNode = new Queue.Node(task, this.head, this.tail);
      this.head = taskNode;
      this.tail = taskNode;
  }
...

If we follow the steps on the Reproduction Steps on the step **5** it could be that the TaskMaster in charge of the alert queue is no longer running or is waiting for a response.

OS & Version Information
Test Case, Sample Code, and / or Example App
int i = 0;
Timer timer = new Timer();
timer.schedule(new TimerTask() {
    @Override
    public void run() {
        sendAlert();
    }
},0,50000);

public void sendAlert() {
  AlertView.Builder builder = new AlertView.Builder();
  builder.setText("text 1");
  builder.setSecondaryText("text 2");
  builder.setSoftButtons(getButtons());
  AlertView alert = builder.build();
  sdlManager.getScreenManager().presentAlert(alert, (success, tryAgainTime) -> {
      DebugTool.logInfo(TAG,"Success: "+ success);
  });
}

private ArrayList<SoftButtonObject> getButtons() {
    SoftButtonState okButtonState = new SoftButtonState("okButtonAlertState","okButtonAlertState",null);
    SoftButtonObject okSoftButtonObj = new SoftButtonObject("okButtonAlert", okButtonState, new 
    SoftButtonObject.OnEventListener() {
        @Override
        public void onPress(SoftButtonObject softButtonObject, OnButtonPress onButtonPress) {
            DebugTool.logInfo(TAG, "OK BUTTON PRESSED");
        }

        @Override
        public void onEvent(SoftButtonObject softButtonObject, OnButtonEvent onButtonEvent) {
            DebugTool.logInfo(TAG, "OK BUTTON "+ onButtonEvent.toString());
        }
    });
    SoftButtonState cancelButtonState = new SoftButtonState("cancelButtonAlertState","cancelButtonState",null);
    SoftButtonObject cancelButtonObj = new SoftButtonObject("cancelButtonAlertState", cancelButtonState, new SoftButtonObject.OnEventListener() {
        @Override
        public void onPress(SoftButtonObject softButtonObject, OnButtonPress onButtonPress) {
            DebugTool.logInfo(TAG, "CANCEL BUTTON PRESSED");
        }

        @Override
        public void onEvent(SoftButtonObject softButtonObject, OnButtonEvent onButtonEvent) {
            DebugTool.logInfo(TAG, "CANCEL BUTTON "+onButtonEvent.toString());
        }
    });
    return new ArrayList<SoftButtonObject>(Arrays.asList(okSoftButtonObj,cancelButtonObj));
}
bilal-alsharifi commented 2 years ago

Hi @mjuarez-ford, we tried to reproduce the issue on Manticore but we were not able to see the issue. We couldn't test the exact scenario on Sync because we don't have an app that has the permissions to send Alerts in the Background on Sync. would be able to see if the issue happens when you test on Manticore? also does the issue happen every time when you go through the same scenario or only rarely?

mjuarez-ford commented 2 years ago

Hi @bilal-alsharifi, I'll try it with Manticore, Yes happens all the time. I will create an app ID with all necessary permissions for the test, who I can share it with you?

bilal-alsharifi commented 2 years ago

@mjuarez-ford Sounds great. Can you send me info on Slack?

mjuarez-ford commented 2 years ago

sure @bilal-alsharifi, I just shared the info there.

mjuarez-ford commented 2 years ago

Hi, @bilal-alsharifi were you able to reproduce it? I was not able to reproduce it in Manticore, but it always happens on Sync3. I can share the SmartDeviceLink Logs from the TDK on Slack if that helps in any way.

joeljfischer commented 2 years ago

Hello @mjuarez-ford, Bilal is no longer working on this project. We have internally reassigned this task and will get back to you when we can. In the meantime, if you can provide (privately) a Sync app id and app name that have these permissions, that would be a great help in tracking this issue down. You can also provide the TDK logs, but they will be more difficult for our engineers to parse and less likely to be useful.

Thank you!

mjuarez-ford commented 2 years ago

Hello @joeljfischer, is there any update on this issue?

joeljfischer commented 2 years ago

Hi @mjuarez-ford, this task has not yet been started, but it should be soon. We have been working through crashing bugs first, but the plan is still for this issue to be investigated and solved before the April release.

mjuarez-ford commented 2 years ago

Thanks so much for the feedback @joeljfischer.

mjuarez-ford commented 2 years ago

Hi @joeljfischer is there any news regarding this issue?

joeljfischer commented 2 years ago

Due to unforeseen circumstances, this bug will not be fixed in the upcoming release. I responded with more detail on Slack.