Fontawesome icon vanishes in editor while switching text and visual mode

I think you should first enable i tags.Then you should enable class id or span whatever you like.To do so add this code.

function add_mce_markup( $initArray ) {
    $ext="i[id|name|class|style]";
    if ( isset( $initArray['extended_valid_elements'] ) ) {
        $initArray['extended_valid_elements'] .= ',' . $ext;
    } else {
        $initArray['extended_valid_elements'] = $ext;
    }
    return $initArray;
}
add_filter( 'tiny_mce_before_init', 'add_mce_markup' );

error code: 523